This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e72bbe3
Showing
40 changed files
with
13,410 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
include '../auth/db.php'; | ||
|
||
// Cek jika request nya itu POST | ||
if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
$id_tabungan = abs((int)$_GET['id_tabungan']); // Mengambil nilai 'id_tabungan' dari parameter GET dan mengonversi menjadi integer positif | ||
|
||
// Menghapus data dari tbl_tabungan_pelajar | ||
$stmt = $conn->prepare("DELETE FROM tbl_tabungan_pelajar WHERE id_tabungan = :id_tabungan"); | ||
$stmt->bindParam(':id_tabungan', $id_tabungan); | ||
$stmt->execute(); | ||
|
||
tutupKoneksi($conn); // Menutup koneksi database dengan memanggil fungsi 'tutupKoneksi' | ||
} else { | ||
header('HTTP/1.1 404 Not found'); // Mengirimkan header respons HTTP 404 jika permintaan bukan metode POST | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
session_start(); | ||
include "../auth/db.php"; | ||
|
||
// Jika peran pengguna adalah 'admin', ambil semua data dari tabel tbl_tabungan_pelajar. | ||
if ($_SESSION['role'] == 'admin') { | ||
$sql = "SELECT id_tabungan, email, nama_lengkap, jenis_kelamin, kelas, angkatan, status, saldo | ||
FROM tbl_tabungan_pelajar"; | ||
|
||
// Jika peran pengguna adalah 'user', ambil data dari tabel tbl_tabungan_pelajar, | ||
// berdasarkan kondisi email tertentu. | ||
} else if ($_SESSION['role'] == 'user') { | ||
$sql = "SELECT id_tabungan, email, nama_lengkap, jenis_kelamin, kelas, angkatan, status, saldo | ||
FROM tbl_tabungan_pelajar WHERE email = :email"; | ||
} | ||
|
||
$stmt = $conn->prepare($sql); // Persiapkan pernyataan SQL menggunakan koneksi $conn. | ||
|
||
// Jika peran pengguna adalah 'user', ikat parameter :email dengan nilai $_SESSION['email']. | ||
if ($_SESSION['role'] == 'user') { | ||
$stmt->bindParam(':email', $_SESSION['email']); | ||
} | ||
|
||
$stmt->execute(); // Jalankan pernyataan SQL yang sudah disiapkan. | ||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC); // Ambil semua hasil dari pernyataan SQL dan simpan dalam $results dengan format asosiatif array. | ||
|
||
?> | ||
|
||
<div class="container-fluid px-4"> | ||
|
||
<div class="card mb-4 mt-5"> | ||
<div class="card-header"> | ||
<i class="fas fa-table me-1"></i> | ||
DataTable Tabungan Pelajar | ||
</div> | ||
|
||
<div class="card-body"> | ||
<?php echo $_SESSION['role'] == 'admin' ? '<button type="button" class="btn btn-success mt-3 mb-3" data-bs-toggle="modal" data-bs-target="#tambahPelajar"><i class="bi bi-plus-circle"></i> Tambah Data</button>' : ''; ?> | ||
<div class="table-responsive"> | ||
<table class="dataTable text-center table table-bordered w-100"> | ||
<thead> | ||
<tr> | ||
|
||
<th class="d-none">-</th> | ||
<th class="border-start flex-fill">No</th> | ||
<th>Email</th> | ||
<th>Nama Lengkap</th> | ||
<th>Jenis Kelamin</th> | ||
<th>Kelas</th> | ||
<th>Angkatan</th> | ||
<th>Status</th> | ||
<th>Saldo</th> | ||
<?php echo $_SESSION['role'] == 'admin' ? '<th>Aksi</th>' : ''; ?> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<?php $no = 1; ?> | ||
<?php foreach ($results as $data) : ?> | ||
|
||
<tr> | ||
<td class="d-none"><?php echo $data['id_tabungan']; ?></td> | ||
<td class="border-start"><?php echo $no++; ?></td> | ||
<td><?php echo $data['email']; ?></td> | ||
<td><?php echo $data['nama_lengkap']; ?></td> | ||
<td><?php echo $data['jenis_kelamin']; ?></td> | ||
<td><?php echo $data['kelas']; ?></td> | ||
<td><?php echo $data['angkatan']; ?></td> | ||
<td><span class="badge <?php echo $data['status'] == 'aktif' ? 'text-bg-success' : 'text-bg-danger'; ?>"> | ||
<?php echo $data['status']; ?> | ||
</span></td> | ||
<td><?php echo $data['saldo']; ?></td> | ||
<?php if ($_SESSION['role'] == 'admin') { ?> | ||
<td> | ||
<div class="d-flex justify-content-center"> | ||
<?php | ||
// Variabel tombol delete dan update | ||
$button_delete = "<a class='btn btn-danger mb-1 mr-1 me-2 mt-3 deleteData' href='deleteData.php?id_tabungan=" . $data['id_tabungan'] . "'><i class='bi bi-trash'></i></a>"; | ||
$button_update = "<a class='btn btn-warning text-white mb-1 mt-3 updateData' data-bs-toggle='modal' data-bs-target='#updatePelajar' href='updateData.php?id_tabungan=" . $data['id_tabungan'] . "'><i class='bi bi-pencil'></i></a>"; | ||
?> | ||
<?php echo "$button_delete $button_update"; ?> | ||
</div> | ||
</td> | ||
<?php } ?> | ||
</tr> | ||
<?php endforeach; ?> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
$(document).ready(function() { | ||
$('.dataTable').DataTable(); | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
session_start(); | ||
include "../auth/db.php"; | ||
|
||
// Mendapatkan informasi gambar yang akan dihapus sebagai gambar lama berdasarkan email | ||
$stmtSelect = $conn->prepare("SELECT foto_profile FROM tbl_profiles WHERE email = :email"); | ||
$stmtSelect->bindParam(':email', $_SESSION['email']); | ||
$stmtSelect->execute(); | ||
$rowImage = $stmtSelect->fetch(PDO::FETCH_ASSOC); | ||
$image = $rowImage['foto_profile']; | ||
|
||
?> | ||
|
||
<img src="img/<?php echo $image; ?>" class="rounded mx-auto d-block mb-1 mt-4 rounded-circle" style="background-color: white;" height="75px;"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
include '../auth/db.php'; | ||
|
||
// Cek jika request nya itu POST | ||
if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
|
||
// Function security input | ||
function securityInput($data) | ||
{ | ||
$data = trim($data); // Menghapus spasi di awal dan akhir string | ||
$data = stripslashes($data); // Menghapus karakter backslash (\) | ||
$data = htmlspecialchars($data); // Mengonversi karakter khusus menjadi entitas HTML agar mencegah serangan XSS | ||
$data = strip_tags($data); // Mengonversi karakter khusus menjadi entitas HTML agar mencegah serangan html injection | ||
return $data; | ||
} | ||
|
||
// Memanggil fungsi security input untuk membersihkan, mengamankan input pada variabel email, nama lengkap, jenis kelamin, kelas | ||
$email = securityInput($_POST['email']); | ||
$nama_lengkap = securityInput($_POST['nama_lengkap']); | ||
$jenis_kelamin = securityInput($_POST['jenis_kelamin']); | ||
$kelas = securityInput($_POST['kelas']); | ||
|
||
// Variabel angkatan | ||
$angkatan = $_POST['angkatan']; | ||
|
||
// Variabel status | ||
$status = $_POST['status']; | ||
|
||
// Variabel saldo dari form input tabungan pelajar | ||
$saldo = $_POST['saldo']; | ||
|
||
// Format saldo | ||
$formatSaldo = number_format($saldo, 0, ".", "."); | ||
|
||
// Tanggal saat ini | ||
$currentDate = date("Y-m-d"); | ||
|
||
// Menyiapkan pernyataan SQL dengan menggunakan parameter placeholder | ||
$sql = "INSERT INTO tbl_tabungan_pelajar (email, nama_lengkap, jenis_kelamin, kelas, angkatan, status, saldo, created_at, updated_at) | ||
VALUES (:email, :nama_lengkap, :jenis_kelamin, :kelas, :angkatan, :status, :saldo, :created_at, :updated_at)"; | ||
$stmt = $conn->prepare($sql); | ||
|
||
// Mengikat nilai-nilai ke parameter-placeholder | ||
$stmt->bindParam(':email', $email); | ||
$stmt->bindParam(':nama_lengkap', $nama_lengkap); | ||
$stmt->bindParam(':jenis_kelamin', $jenis_kelamin); | ||
$stmt->bindParam(':kelas', $kelas); | ||
$stmt->bindParam(':angkatan', $angkatan); | ||
$stmt->bindParam(':status', $status); | ||
$stmt->bindParam(':saldo', $formatSaldo); | ||
$stmt->bindParam(':created_at', $currentDate); | ||
$stmt->bindParam(':updated_at', $currentDate); | ||
|
||
// Cek jika berhasil di eksekusi | ||
if ($stmt->execute()) { | ||
|
||
// Beri response | ||
$response = array( | ||
'success' => true, | ||
'message' => 'Data pelajar berhasil disimpan.' | ||
); | ||
echo json_encode($response); | ||
|
||
// Mengecek jika ada kesalahan pada backend web aplikasi | ||
} else { | ||
|
||
// Beri response | ||
$response = array( | ||
'success' => false, | ||
'message' => 'Terjadi kesalahan saat menyimpan data pelajar.' | ||
); | ||
echo json_encode($response); | ||
} | ||
|
||
// Tutup koneksi | ||
tutupKoneksi($conn); | ||
} else { | ||
header('HTTP/1.1 404 Not found'); // Mengirimkan header respons HTTP 404 jika permintaan bukan metode POST | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
include '../auth/db.php'; | ||
|
||
// Cek jika request nya itu POST | ||
if ($_SERVER["REQUEST_METHOD"] == "POST") { | ||
|
||
// Function security input | ||
function securityInput($data) | ||
{ | ||
$data = trim($data); // Menghapus spasi di awal dan akhir string | ||
$data = stripslashes($data); // Menghapus karakter backslash (\) | ||
$data = htmlspecialchars($data); // Mengonversi karakter khusus menjadi entitas HTML agar mencegah serangan XSS | ||
$data = strip_tags($data); // Mengonversi karakter khusus menjadi entitas HTML agar mencegah serangan html injection | ||
return $data; | ||
} | ||
|
||
$id_tabungan = abs((int)$_POST['id_tabungan']); | ||
|
||
// Memanggil fungsi security input untuk membersihkan, mengamankan input pada variabel email, nama lengkap, jenis kelamin, kelas | ||
$email = securityInput($_POST['email']); | ||
$nama_lengkap = securityInput($_POST['nama_lengkap']); | ||
$jenis_kelamin = securityInput($_POST['jenis_kelamin']); | ||
$kelas = securityInput($_POST['kelas']); | ||
|
||
// Variabel angkatan | ||
$angkatan = $_POST['angkatan']; | ||
|
||
// Variabel status | ||
$status = $_POST['status']; | ||
|
||
// Variabel saldo dari form input tabungan pelajar | ||
$saldo = $_POST['saldo']; | ||
|
||
// Format saldo | ||
$formatSaldo = number_format($saldo, 0, ".", "."); | ||
|
||
// Tanggal saat ini | ||
$currentDate = date("Y-m-d"); | ||
|
||
// Menyiapkan pernyataan SQL dengan menggunakan parameter placeholder | ||
$sql = "UPDATE tbl_tabungan_pelajar SET | ||
email = :email, | ||
nama_lengkap = :nama_lengkap, | ||
jenis_kelamin = :jenis_kelamin, | ||
kelas = :kelas, | ||
angkatan = :angkatan, | ||
status = :status, | ||
saldo = :saldo, | ||
updated_at = :updated_at | ||
WHERE id_tabungan = :id_tabungan"; | ||
|
||
$stmt = $conn->prepare($sql); | ||
|
||
// Mengikat nilai-nilai ke parameter-placeholder | ||
$stmt->bindParam(':email', $email); | ||
$stmt->bindParam(':nama_lengkap', $nama_lengkap); | ||
$stmt->bindParam(':jenis_kelamin', $jenis_kelamin); | ||
$stmt->bindParam(':kelas', $kelas); | ||
$stmt->bindParam(':angkatan', $angkatan); | ||
$stmt->bindParam(':status', $status); | ||
$stmt->bindParam(':saldo', $formatSaldo); | ||
$stmt->bindParam(':updated_at', $currentDate); | ||
$stmt->bindParam(':id_tabungan', $id_tabungan); | ||
|
||
// Cek jika berhasil di eksekusi | ||
if ($stmt->execute()) { | ||
|
||
// Beri response | ||
$response = array( | ||
'success' => true, | ||
'message' => 'Data pelajar berhasil diupdate.' | ||
); | ||
echo json_encode($response); | ||
|
||
// Mengecek jika ada kesalahan pada backend web aplikasi | ||
} else { | ||
|
||
// Beri response | ||
$response = array( | ||
'success' => false, | ||
'message' => 'Terjadi kesalahan saat mengupdate data pelajar.' | ||
); | ||
echo json_encode($response); | ||
} | ||
|
||
// Tutup koneksi | ||
tutupKoneksi($conn); | ||
} else { | ||
header('HTTP/1.1 404 Not found'); // Mengirimkan header respons HTTP 404 jika permintaan bukan metode POST | ||
} |
Oops, something went wrong.