205 lines
6.8 KiB
PHP
205 lines
6.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';
|
|
|
|
// Query untuk menghitung total saldo
|
|
$saldo_query = "SELECT
|
|
SUM(kas_pemasukan) AS total_pemasukan,
|
|
SUM(kas_pengeluaran) AS total_pengeluaran
|
|
FROM dana_kas";
|
|
$saldo_result = mysqli_query($conn, $saldo_query);
|
|
$saldo_data = mysqli_fetch_assoc($saldo_result);
|
|
$total_saldo = $saldo_data['total_pemasukan'] - $saldo_data['total_pengeluaran'];
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="id">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta content="width=device-width, initial-scale=1.0" name="viewport">
|
|
|
|
<title>Ikhtisar Kas - 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">
|
|
|
|
<!-- Add jQuery -->
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<?php
|
|
include '../forms/section/header.php';
|
|
include '../forms/section/sidebar.php';
|
|
?>
|
|
|
|
<main id="main" class="main">
|
|
|
|
<div class="pagetitle">
|
|
<h1>Ikhtisar Kas</h1>
|
|
<nav>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="dashboard.php">Home</a></li>
|
|
<li class="breadcrumb-item active">Ikhtisar Kas</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 Kas</h5>
|
|
<!-- Total Saldo -->
|
|
<div class="alert alert-info" role="alert">
|
|
<h4 class="mb-0">Total Saldo: Rp <?php echo number_format($total_saldo, 0, ',', '.'); ?></h4>
|
|
</div>
|
|
<!-- Search Bar & Buttons -->
|
|
<div class="row mb-3">
|
|
<div class="col-md-8 d-flex gap-2">
|
|
<input type="text" id="search_keterangan" class="form-control" placeholder="Cari keterangan...">
|
|
<input type="month" id="search_bulan" class="form-control">
|
|
<button id="reset_filter" class="btn btn-secondary">Reset</button>
|
|
</div>
|
|
<div class="col-md-4 text-end">
|
|
<!-- Tombol Cetak -->
|
|
<button id="btn_cetak" class="btn btn-success"><i class="fas fa-print"></i> Cetak</button>
|
|
|
|
<!-- Tombol Tambah Dana -->
|
|
<a href="tambah_ikhtisarkas.php" class="btn btn-primary">Tambahkan Dana Kas</a>
|
|
</div>
|
|
</div>
|
|
<!-- Table with striped rows -->
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>No</th>
|
|
<th>Kas Pemasukan</th>
|
|
<th>Kas Pengeluaran</th>
|
|
<th>Kas Keterangan</th>
|
|
<th>Kas Jenis</th>
|
|
<th>Kas Tanggal</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="kas-data">
|
|
<!-- Data akan dimuat di sini dengan AJAX -->
|
|
</tbody>
|
|
</table>
|
|
<!-- Navigasi Pagination -->
|
|
<div class="pagination-wrapper-container">
|
|
<div class="d-flex justify-content-between pagination-mobile-wrapper">
|
|
<button id="prev_page" class="btn btn-outline-primary">< Sebelumnya</button>
|
|
<span id="page_info"></span>
|
|
<button id="next_page" class="btn btn-outline-primary">Selanjutnya ></button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</main>
|
|
|
|
<?php include('../forms/section/footer.php'); ?>
|
|
|
|
<script>
|
|
$(document).ready(function(){
|
|
let currentPage = 1;
|
|
|
|
function loadData(search_keterangan = '', search_bulan = '', page = 1) {
|
|
$.ajax({
|
|
url: "search_ikhtisarkas.php",
|
|
type: "GET",
|
|
data: { search_keterangan, search_bulan, page },
|
|
success: function(data) {
|
|
let response = JSON.parse(data);
|
|
$("#kas-data").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);
|
|
}
|
|
});
|
|
}
|
|
|
|
// Load data awal
|
|
loadData();
|
|
|
|
// Event pencarian berdasarkan keterangan
|
|
$("#search_keterangan").on("keyup", function() {
|
|
currentPage = 1;
|
|
loadData($(this).val(), $("#search_bulan").val(), currentPage);
|
|
});
|
|
|
|
// Event pencarian berdasarkan bulan
|
|
$("#search_bulan").on("change", function() {
|
|
currentPage = 1;
|
|
loadData($("#search_keterangan").val(), $(this).val(), currentPage);
|
|
});
|
|
|
|
// Tombol reset filter
|
|
$("#reset_filter").on("click", function() {
|
|
$("#search_keterangan").val('');
|
|
$("#search_bulan").val('');
|
|
currentPage = 1;
|
|
loadData();
|
|
});
|
|
|
|
// Pagination: Next & Previous
|
|
$("#prev_page").on("click", function() {
|
|
if (currentPage > 1) {
|
|
currentPage--;
|
|
loadData($("#search_keterangan").val(), $("#search_bulan").val(), currentPage);
|
|
}
|
|
});
|
|
|
|
$("#next_page").on("click", function() {
|
|
currentPage++;
|
|
loadData($("#search_keterangan").val(), $("#search_bulan").val(), currentPage);
|
|
});
|
|
});
|
|
|
|
$(document).ready(function(){
|
|
$("#btn_cetak").on("click", function(){
|
|
let searchBulan = $("#search_bulan").val();
|
|
if (searchBulan === "") {
|
|
alert("Silakan pilih bulan terlebih dahulu sebelum mencetak.");
|
|
} else {
|
|
window.open("cetak_ikhtisarkas.php?bulan=" + searchBulan, "_blank");
|
|
}
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|