229 lines
7.8 KiB
PHP
229 lines
7.8 KiB
PHP
<?php
|
|
session_start();
|
|
// Cek apakah pengguna sudah login
|
|
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
|
header('Location: ../auth/login.php');
|
|
exit;
|
|
}
|
|
|
|
// Include file koneksi ke database
|
|
include '../config/database.php';
|
|
|
|
// Konfigurasi Pagination
|
|
$limit = 10;
|
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
|
if ($page < 1) $page = 1;
|
|
$offset = ($page - 1) * $limit;
|
|
|
|
// Hitung total data
|
|
$total_result = mysqli_query($conn, "SELECT COUNT(*) as total FROM donasi");
|
|
$total_row = mysqli_fetch_assoc($total_result);
|
|
$total_data = $total_row['total'];
|
|
$total_pages = ceil($total_data / $limit);
|
|
|
|
// Query data dengan pagination
|
|
$query = "SELECT * FROM donasi ORDER BY donasi_id DESC LIMIT $limit OFFSET $offset";
|
|
$result = mysqli_query($conn, $query);
|
|
?>
|
|
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
|
|
|
<title>Konfirmasi Donasi - Masjid-E</title>
|
|
<meta content="" name="description">
|
|
<meta content="" name="keywords">
|
|
|
|
<!-- Favicons -->
|
|
<link href="../assets/img/favicon.png" rel="icon">
|
|
<link href="../assets/img/apple-touch-icon.png" rel="apple-touch-icon">
|
|
|
|
<!-- Google Fonts -->
|
|
<link href="https://fonts.gstatic.com" rel="preconnect">
|
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700" rel="stylesheet">
|
|
<!-- Vendor CSS Files -->
|
|
<link href="../assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="../assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
|
|
<link href="../assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
|
|
<link href="../assets/vendor/quill/quill.snow.css" rel="stylesheet">
|
|
<link href="../assets/vendor/quill/quill.bubble.css" rel="stylesheet">
|
|
<link href="../assets/vendor/remixicon/remixicon.css" rel="stylesheet">
|
|
<link href="../assets/vendor/simple-datatables/style.css" rel="stylesheet">
|
|
|
|
<!-- Template Main CSS File -->
|
|
<link href="../assets/css/admin.css" rel="stylesheet">
|
|
|
|
<!-- Lightbox2 CSS -->
|
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.3/css/lightbox.min.css" rel="stylesheet">
|
|
|
|
<!-- Add jQuery -->
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
<!-- Include admin.js -->
|
|
<script src="../assets/js/admin.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<?php
|
|
include '../forms/section/header.php';
|
|
include '../forms/section/sidebar.php';
|
|
?>
|
|
|
|
<main id="main" class="main">
|
|
|
|
<div class="pagetitle">
|
|
<h1>Konfirmasi Donasi</h1>
|
|
<nav>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="dashboard.php">Home</a></li>
|
|
<li class="breadcrumb-item active">Konfirmasi Donasi</li>
|
|
</ol>
|
|
</nav>
|
|
</div><!-- End Page Title -->
|
|
|
|
<section class="section">
|
|
<div class="row">
|
|
<div class="col-lg-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Data Donasi</h5>
|
|
<!-- Table with striped rows -->
|
|
<table class="table table-striped" id="donasi-table">
|
|
<thead>
|
|
<tr>
|
|
<th>No</th>
|
|
<th>Nama Donatur</th>
|
|
<th>Jumlah Donasi</th>
|
|
<th>Metode Donasi</th>
|
|
<th>Keterangan</th>
|
|
<th>Bukti Donasi</th>
|
|
<th>Status</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$no = $offset + 1;
|
|
while ($row = mysqli_fetch_assoc($result)): ?>
|
|
<tr>
|
|
<td><?php echo $no++; ?></td>
|
|
<td><?php echo htmlspecialchars($row['donasi_nama']); ?></td>
|
|
<td>Rp <?php echo number_format($row['donasi_jumlah'], 0, ',', '.'); ?></td>
|
|
<td><?php echo htmlspecialchars($row['donasi_metode']); ?></td>
|
|
<td><?php echo htmlspecialchars($row['donasi_keterangan']); ?></td>
|
|
<td>
|
|
<?php if (!empty($row['donasi_gambar'])): ?>
|
|
<a href="../assets/img/donasi/<?php echo htmlspecialchars($row['donasi_gambar']); ?>" data-lightbox="donasi" data-title="Bukti Donasi">
|
|
<img src="../assets/img/donasi/<?php echo htmlspecialchars($row['donasi_gambar']); ?>" alt="Gambar Donasi" style="width: 70px; height: 70px;">
|
|
</a>
|
|
<?php else: ?>
|
|
Tidak ada gambar
|
|
<?php endif; ?>
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-<?php echo $row['status'] == 'Pending' ? 'warning' : 'success'; ?>">
|
|
<?php echo $row['status']; ?>
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<?php if ($row['status'] == 'Pending'): ?>
|
|
<button class="btn btn-success btn-sm" onclick="konfirmasiDonasi(<?php echo $row['donasi_id']; ?>)">
|
|
Konfirmasi
|
|
</button>
|
|
<?php else: ?>
|
|
<button class="btn btn-secondary btn-sm" disabled>Confirmed</button>
|
|
<?php endif; ?>
|
|
</td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
<!-- Navigasi Pagination -->
|
|
<div class="pagination-wrapper-container mt-3">
|
|
<div class="d-flex justify-content-between pagination-mobile-wrapper">
|
|
<?php if ($page > 1): ?>
|
|
<a href="?page=<?php echo $page - 1; ?>" class="btn btn-outline-primary" id="prev_page">< Sebelumnya</a>
|
|
<?php else: ?>
|
|
<button class="btn btn-outline-secondary" disabled id="prev_page">< Sebelumnya</button>
|
|
<?php endif; ?>
|
|
|
|
<span id="page_info">Halaman <?php echo $page; ?> dari <?php echo $total_pages; ?></span>
|
|
|
|
<?php if ($page < $total_pages): ?>
|
|
<a href="?page=<?php echo $page + 1; ?>" class="btn btn-outline-primary" id="next_page">Selanjutnya ></a>
|
|
<?php else: ?>
|
|
<button class="btn btn-outline-secondary" disabled id="next_page">Selanjutnya ></button>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
</main><!-- End #main -->
|
|
|
|
<?php include('../forms/section/footer.php'); ?>
|
|
|
|
<!-- Lightbox2 JS -->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.3/js/lightbox.min.js"></script>
|
|
|
|
<script>
|
|
function konfirmasiDonasi(donasiId) {
|
|
if (confirm("Apakah Anda yakin ingin mengonfirmasi donasi ini?")) {
|
|
$.ajax({
|
|
url: 'update_status_donasi.php',
|
|
type: 'POST',
|
|
data: { id: donasiId },
|
|
success: function(response) {
|
|
alert(response);
|
|
location.reload();
|
|
},
|
|
error: function(xhr, status, error) {
|
|
alert('Terjadi kesalahan: ' + error);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
let currentPage = 1;
|
|
|
|
function loadDonasiData(page = 1) {
|
|
$.ajax({
|
|
url: "search_konfirmasi_donasi.php",
|
|
type: "GET",
|
|
data: { page: page },
|
|
success: function(data) {
|
|
let response = JSON.parse(data);
|
|
$("#donasi-table tbody").html(response.data);
|
|
$("#page_info").text("Halaman " + response.current_page + " dari " + response.total_pages);
|
|
|
|
$("#prev_page").prop("disabled", response.current_page <= 1);
|
|
$("#next_page").prop("disabled", response.current_page >= response.total_pages);
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
loadDonasiData();
|
|
|
|
$("#prev_page").on("click", function() {
|
|
if (currentPage > 1) {
|
|
currentPage--;
|
|
loadDonasiData(currentPage);
|
|
}
|
|
});
|
|
|
|
$("#next_page").on("click", function() {
|
|
currentPage++;
|
|
loadDonasiData(currentPage);
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|