From 19cc3244dec995483cb83a01f551da716732b2bf Mon Sep 17 00:00:00 2001 From: wartana Date: Thu, 22 Jan 2026 15:52:22 +0800 Subject: [PATCH] Enhance pendatang module with existing resident selection, standardize UI gender display to LAKI-LAKI/PEREMPUAN, add Jenis Kelamin columns to pindah/mendu tables, fix NIK display in reports, and implement security improvements --- add_dummy_data.sql | 30 ++++++ admin/datang/add_datang.php | 166 +++++++++++++++--------------- admin/datang/data_datang.php | 12 ++- admin/datang/edit_datang.php | 173 ++++++++++++++++++-------------- admin/kartu/anggota.php | 12 ++- admin/kartu/anggota_full.php | 12 ++- admin/lahir/add_lahir.php | 145 +++++++++++++------------- admin/lahir/data_lahir.php | 12 ++- admin/mendu/add_mendu.php | 70 +++++++------ admin/mendu/data_mendu.php | 28 +++--- admin/mendu/view_mendu.php | 10 +- admin/pend/add_pend.php | 29 +++--- admin/pend/data_pend.php | 12 ++- admin/pengguna/add_pengguna.php | 56 ++++++----- admin/pindah/add_pindah.php | 70 +++++++------ admin/pindah/data_pindah.php | 28 +++--- admin/pindah/view_pindah.php | 10 +- inc/koneksi.php | 2 + index.php | 10 +- init.sql | 2 +- report/cetak_datang.php | 30 ++++-- report/cetak_domisili.php | 8 +- report/cetak_klasifikasi.php | 14 ++- report/cetak_lahir.php | 18 +++- report/cetak_mati.php | 8 +- report/cetak_pindah.php | 8 +- report/laporan_datang.php | 14 ++- report/laporan_lahir.php | 10 +- report/laporan_mendu.php | 2 +- report/laporan_penduduk.php | 14 ++- report/laporan_pindah.php | 2 +- surat/suket_datang.php | 8 +- surat/suket_domisili.php | 4 +- surat/suket_lahir.php | 4 +- surat/suket_mati.php | 2 +- surat/suket_pindah.php | 47 ++++----- 36 files changed, 648 insertions(+), 434 deletions(-) create mode 100644 add_dummy_data.sql diff --git a/add_dummy_data.sql b/add_dummy_data.sql new file mode 100644 index 0000000..ca93857 --- /dev/null +++ b/add_dummy_data.sql @@ -0,0 +1,30 @@ +-- Add dummy population data for donut chart testing +-- Balita (0-5 years) - 5 records +INSERT INTO tb_pdd (id_pend, nik, nama, tempat_lh, tgl_lh, jekel, desa, rt, rw, agama, kawin, pekerjaan, status) VALUES +(16, '3201010101001001', 'Balita 1', 'Bogor', '2023-01-15', 'LK', 'Sukamaju', '01', '02', 'Islam', 'Belum', 'Balita', 'Ada'), +(17, '3201010101001002', 'Balita 2', 'Bogor', '2022-06-30', 'PR', 'Sukamaju', '01', '02', 'Islam', 'Belum', 'Balita', 'Ada'), +(18, '3201010101001003', 'Balita 3', 'Bogor', '2021-03-20', 'LK', 'Sukamaju', '01', '02', 'Islam', 'Belum', 'Balita', 'Ada'), +(19, '3201010101001004', 'Balita 4', 'Bogor', '2020-11-10', 'PR', 'Sukamaju', '02', '03', 'Islam', 'Belum', 'Balita', 'Ada'), +(20, '3201010101001005', 'Balita 5', 'Bogor', '2024-02-28', 'LK', 'Sukamaju', '02', '03', 'Islam', 'Belum', 'Balita', 'Ada'); + +-- Anak-anak (6-12 years) - 5 records +INSERT INTO tb_pdd (id_pend, nik, nama, tempat_lh, tgl_lh, jekel, desa, rt, rw, agama, kawin, pekerjaan, status) VALUES +(21, '3201010101001006', 'Anak 1', 'Bogor', '2018-05-15', 'LK', 'Sukamaju', '01', '02', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(22, '3201010101001007', 'Anak 2', 'Bogor', '2017-08-20', 'PR', 'Sukamaju', '01', '02', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(23, '3201010101001008', 'Anak 3', 'Bogor', '2016-12-10', 'LK', 'Sukamaju', '02', '03', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(24, '3201010101001009', 'Anak 4', 'Bogor', '2015-04-25', 'PR', 'Sukamaju', '02', '03', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(25, '3201010101001010', 'Anak 5', 'Bogor', '2014-09-05', 'LK', 'Sukamaju', '03', '04', 'Islam', 'Belum', 'Pelajar', 'Ada'); + +-- Remaja (13-17 years) - 5 records +INSERT INTO tb_pdd (id_pend, nik, nama, tempat_lh, tgl_lh, jekel, desa, rt, rw, agama, kawin, pekerjaan, status) VALUES +(26, '3201010101001011', 'Remaja 1', 'Bogor', '2011-07-15', 'LK', 'Sukamaju', '01', '02', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(27, '3201010101001012', 'Remaja 2', 'Bogor', '2010-03-20', 'PR', 'Sukamaju', '01', '02', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(28, '3201010101001013', 'Remaja 3', 'Bogor', '2009-11-30', 'LK', 'Sukamaju', '02', '03', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(29, '3201010101001014', 'Remaja 4', 'Bogor', '2008-06-10', 'PR', 'Sukamaju', '02', '03', 'Islam', 'Belum', 'Pelajar', 'Ada'), +(30, '3201010101001015', 'Remaja 5', 'Bogor', '2007-01-25', 'LK', 'Sukamaju', '03', '04', 'Islam', 'Belum', 'Pelajar', 'Ada'); + +-- Lansia (60+ years) - 3 records +INSERT INTO tb_pdd (id_pend, nik, nama, tempat_lh, tgl_lh, jekel, desa, rt, rw, agama, kawin, pekerjaan, status) VALUES +(31, '3201010101001016', 'Lansia 1', 'Bogor', '1960-05-15', 'LK', 'Sukamaju', '01', '02', 'Islam', 'Kawin', 'Pensiunan', 'Ada'), +(32, '3201010101001017', 'Lansia 2', 'Bogor', '1958-08-20', 'PR', 'Sukamaju', '01', '02', 'Islam', 'Cerai Mati', 'Pensiunan', 'Ada'), +(33, '3201010101001018', 'Lansia 3', 'Bogor', '1955-12-10', 'LK', 'Sukamaju', '02', '03', 'Islam', 'Kawin', 'Pensiunan', 'Ada'); \ No newline at end of file diff --git a/admin/datang/add_datang.php b/admin/datang/add_datang.php index 56d82ea..eb4bc0e 100644 --- a/admin/datang/add_datang.php +++ b/admin/datang/add_datang.php @@ -1,3 +1,6 @@ +

@@ -6,37 +9,40 @@
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
+
+ +
+ +
+ +
+ +
+ +
+ +
+
@@ -50,9 +56,9 @@ while ($row = mysqli_fetch_array($hasil)) { ?> - Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' - }).then((result) => {if (result.value){ - window.location = 'index.php?page=data-datang'; - } - })"; - }else{ - echo ""; - }} + if (isset ($_POST['Simpan'])){ + //mulai proses simpan data + + // Sanitize Input to prevent SQL Injection & Syntax Errors + $id_pend = (int)$_POST['id_pend']; // Cast to integer for safety + $tgl_datang = mysqli_real_escape_string($koneksi, trim($_POST['tgl_datang'])); + $pelapor = (int)$_POST['pelapor']; // Cast to integer for safety + + // Ambil data penduduk yang dipilih + $sql_pend = "SELECT nik, nama, jekel FROM tb_pdd WHERE id_pend='$id_pend'"; + $q_pend = mysqli_query($koneksi, $sql_pend); + $d_pend = mysqli_fetch_array($q_pend); + + if (!$d_pend) { + die("Data penduduk tidak ditemukan. Silakan pilih penduduk yang valid."); + } + + $nik = mysqli_real_escape_string($koneksi, trim($d_pend['nik'])); + $nama_datang = mysqli_real_escape_string($koneksi, trim($d_pend['nama'])); + $jekel = mysqli_real_escape_string($koneksi, trim($d_pend['jekel'])); + + $sql_simpan = "INSERT INTO tb_datang (id_pend, nik, nama_datang, jekel, tgl_datang, pelapor) VALUES ( + '$id_pend', + '$nik', + '$nama_datang', + '$jekel', + '$tgl_datang', + '$pelapor')"; + $query_simpan = mysqli_query($koneksi, $sql_simpan); + + mysqli_close($koneksi); + + if ($query_simpan) { + echo ""; + }else{ + echo ""; + }} //selesai proses simpan data diff --git a/admin/datang/data_datang.php b/admin/datang/data_datang.php index 37f3467..0cbb054 100644 --- a/admin/datang/data_datang.php +++ b/admin/datang/data_datang.php @@ -17,7 +17,7 @@ No NIK Nama - Jekel + Jenis Kelamin Tanggal Pelapor Aksi @@ -43,7 +43,15 @@ - + diff --git a/admin/datang/edit_datang.php b/admin/datang/edit_datang.php index 2f6ef2a..58b5725 100644 --- a/admin/datang/edit_datang.php +++ b/admin/datang/edit_datang.php @@ -1,11 +1,14 @@
@@ -24,43 +27,51 @@
-
- -
- -
-
- -
- -
- -
-
- -
- + + +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+
- -
-
- -
- -
-
@@ -72,15 +83,14 @@ -
- - Swal.fire({title: 'Ubah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' - }).then((result) => {if (result.value) - {window.location = 'index.php?page=data-datang'; - } - })"; - }else{ - echo ""; - }} + + Swal.fire({title: 'Ubah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' + }).then((result) => {if (result.value) + {window.location = 'index.php?page=data-datang'; + } + })"; + }else{ + echo ""; + }} diff --git a/admin/kartu/anggota.php b/admin/kartu/anggota.php index 1dc6c3b..1a384b3 100644 --- a/admin/kartu/anggota.php +++ b/admin/kartu/anggota.php @@ -97,7 +97,7 @@ NIK Nama - Jekel + Jenis Kelamin Hub Keluarga Aksi @@ -119,7 +119,15 @@ - + diff --git a/admin/kartu/anggota_full.php b/admin/kartu/anggota_full.php index b523b43..77b2939 100644 --- a/admin/kartu/anggota_full.php +++ b/admin/kartu/anggota_full.php @@ -59,7 +59,7 @@ No NIK Nama - Jekel + Jenis Kelamin Hub Keluarga Status @@ -85,7 +85,15 @@ - + diff --git a/admin/lahir/add_lahir.php b/admin/lahir/add_lahir.php index db9cfa5..2161545 100644 --- a/admin/lahir/add_lahir.php +++ b/admin/lahir/add_lahir.php @@ -27,16 +27,16 @@

-
- -
- -
-
+
+ +
+ +
+
@@ -69,62 +69,69 @@
- - Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' - }).then((result) => {if (result.value){ - window.location = 'index.php?page=data-lahir'; - } - })"; - }else{ - echo ""; - }} - //selesai proses simpan data + + Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' + }).then((result) => {if (result.value){ + window.location = 'index.php?page=data-lahir'; + } + })"; + }else{ + echo ""; + }} + //selesai proses simpan data diff --git a/admin/lahir/data_lahir.php b/admin/lahir/data_lahir.php index ff37d30..ff561b1 100644 --- a/admin/lahir/data_lahir.php +++ b/admin/lahir/data_lahir.php @@ -17,7 +17,7 @@ No Nama Tgl Lahir - Jekel + Jenis Kelamin Keluarga Aksi @@ -42,7 +42,15 @@ - + - diff --git a/admin/mendu/add_mendu.php b/admin/mendu/add_mendu.php index 0e203a6..6c30c7f 100644 --- a/admin/mendu/add_mendu.php +++ b/admin/mendu/add_mendu.php @@ -52,35 +52,41 @@
- - Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' - }).then((result) => {if (result.value){ - window.location = 'index.php?page=data-mendu'; - } - })"; - }else{ - echo ""; - }} - //selesai proses simpan data + + Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' + }).then((result) => {if (result.value){ + window.location = 'index.php?page=data-mendu'; + } + })"; + }else{ + echo ""; + }} + //selesai proses simpan data diff --git a/admin/mendu/data_mendu.php b/admin/mendu/data_mendu.php index f0ee18f..2163675 100644 --- a/admin/mendu/data_mendu.php +++ b/admin/mendu/data_mendu.php @@ -13,20 +13,21 @@
- - - - - - - - + + + + + + + + + query("SELECT p.id_pend, p.nik, p.nama, m.tgl_mendu, m.sebab, m.id_mendu from + $sql = $koneksi->query("SELECT p.id_pend, p.nik, p.nama, p.jekel, m.tgl_mendu, m.sebab, m.id_mendu from tb_mendu m inner join tb_pdd p on p.id_pend=m.id_pdd"); while ($data= $sql->fetch_assoc()) { ?> @@ -41,9 +42,12 @@ - + + diff --git a/admin/mendu/view_mendu.php b/admin/mendu/view_mendu.php index 0b1faa1..a89dc84 100644 --- a/admin/mendu/view_mendu.php +++ b/admin/mendu/view_mendu.php @@ -90,7 +90,15 @@ Jenis Kelamin diff --git a/admin/pend/add_pend.php b/admin/pend/add_pend.php index 84194cd..a4dcb17 100644 --- a/admin/pend/add_pend.php +++ b/admin/pend/add_pend.php @@ -1,3 +1,6 @@ +

@@ -385,12 +388,12 @@ window.addEventListener('load', function() { $nik = mysqli_real_escape_string($koneksi, trim($_POST['nik'])); $cek_nik = mysqli_query($koneksi, "SELECT * FROM tb_pdd WHERE nik='$nik'"); if(mysqli_num_rows($cek_nik) > 0){ - echo ""; + echo ""; return; } @@ -432,6 +435,7 @@ window.addEventListener('load', function() { if ($query_simpan) { $id_pend_baru = mysqli_insert_id($koneksi); + $redirect_url = !empty($return_to) ? "index.php?page=" . $return_to . "&selected_id=" . $id_pend_baru : "index.php?page=data-pend"; // KTP → KK: Cari KK yang cocok berdasarkan alamat $sql_cari_kk = "SELECT k.id_kk, k.no_kk, k.kepala, k.desa, k.rt, k.rw @@ -479,16 +483,16 @@ window.addEventListener('load', function() { }).then(resp => resp.json()).then(data => { if(data.success) { Swal.fire('Berhasil!', 'Data telah dihubungkan dengan KK.', 'success').then(() => { - window.location = 'index.php?page=data-pend'; + window.location = '$redirect_url'; }); } else { Swal.fire('Gagal', 'Gagal menghubungkan: ' + data.message, 'error').then(() => { - window.location = 'index.php?page=data-pend'; + window.location = '$redirect_url'; }); } }); } else { - window.location = 'index.php?page=data-pend'; + window.location = '$redirect_url'; } }); "; @@ -497,7 +501,7 @@ window.addEventListener('load', function() { echo ""; } @@ -506,15 +510,16 @@ window.addEventListener('load', function() { echo ""; } } else { + $error_redirect = 'index.php?page=add-pend' . (!empty($return_to) ? '&return_to=' . $return_to : ''); echo ""; } diff --git a/admin/pend/data_pend.php b/admin/pend/data_pend.php index 1b58a51..cfe1073 100644 --- a/admin/pend/data_pend.php +++ b/admin/pend/data_pend.php @@ -17,7 +17,7 @@

- + @@ -59,7 +59,15 @@ - + @@ -67,11 +67,19 @@ ?> - + - + diff --git a/report/cetak_lahir.php b/report/cetak_lahir.php index 8b71f8e..10460b4 100644 --- a/report/cetak_lahir.php +++ b/report/cetak_lahir.php @@ -1,9 +1,11 @@ Jenis Kelamin diff --git a/report/cetak_mati.php b/report/cetak_mati.php index 315bb4c..dd587a0 100644 --- a/report/cetak_mati.php +++ b/report/cetak_mati.php @@ -1,9 +1,11 @@ No - + @@ -44,9 +44,17 @@ ?> - + - + diff --git a/report/laporan_lahir.php b/report/laporan_lahir.php index a3fb305..31e8e2d 100644 --- a/report/laporan_lahir.php +++ b/report/laporan_lahir.php @@ -45,7 +45,15 @@ - + diff --git a/report/laporan_mendu.php b/report/laporan_mendu.php index aab2812..876c33c 100644 --- a/report/laporan_mendu.php +++ b/report/laporan_mendu.php @@ -43,7 +43,7 @@ ?> - + diff --git a/report/laporan_penduduk.php b/report/laporan_penduduk.php index 7808514..65309b8 100644 --- a/report/laporan_penduduk.php +++ b/report/laporan_penduduk.php @@ -28,7 +28,7 @@ - + @@ -42,9 +42,17 @@ ?> - + - + diff --git a/report/laporan_pindah.php b/report/laporan_pindah.php index ce168a2..259029a 100644 --- a/report/laporan_pindah.php +++ b/report/laporan_pindah.php @@ -43,7 +43,7 @@ ?> - + diff --git a/surat/suket_datang.php b/surat/suket_datang.php index 2f4a532..067b71a 100644 --- a/surat/suket_datang.php +++ b/surat/suket_datang.php @@ -3,7 +3,7 @@

Su-Ket Pendatang

- +
@@ -18,9 +18,9 @@ while ($row = mysqli_fetch_array($hasil)) { ?>
\ No newline at end of file diff --git a/surat/suket_domisili.php b/surat/suket_domisili.php index 71b9879..0b0f04d 100644 --- a/surat/suket_domisili.php +++ b/surat/suket_domisili.php @@ -3,7 +3,7 @@

Su-Ket Domisili

- +
@@ -31,7 +31,7 @@
\ No newline at end of file diff --git a/surat/suket_lahir.php b/surat/suket_lahir.php index a4db3e2..f27c6b4 100644 --- a/surat/suket_lahir.php +++ b/surat/suket_lahir.php @@ -3,13 +3,13 @@

Su-Ket Kelahiran

- +
- Su-Ket Kematian
- +
diff --git a/surat/suket_pindah.php b/surat/suket_pindah.php index 85ae1cf..e9d7044 100644 --- a/surat/suket_pindah.php +++ b/surat/suket_pindah.php @@ -3,31 +3,32 @@

Su-Ket Pindah

- +
-
- -
- -
-
+
+ +
+ +
+
NoNIKNamaTanggalSebabAksi
NoNIKNamaJenis KelaminTanggalSebabAksi
- - + + + + : - +
No NIK NamaJKJenis Kelamin Alamat No KK Aksi - + diff --git a/admin/pengguna/add_pengguna.php b/admin/pengguna/add_pengguna.php index 178110c..641d7af 100644 --- a/admin/pengguna/add_pengguna.php +++ b/admin/pengguna/add_pengguna.php @@ -46,8 +46,8 @@ - - Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' - }).then((result) => {if (result.value){ - window.location = 'index.php?page=data-pengguna'; - } - })"; - }else{ - echo ""; - }} - //selesai proses simpan data + mysqli_close($koneksi); + + if ($query_simpan) { + echo ""; + }else{ + echo ""; + }} + //selesai proses simpan data diff --git a/admin/pindah/add_pindah.php b/admin/pindah/add_pindah.php index c9cd9b3..1143f3a 100644 --- a/admin/pindah/add_pindah.php +++ b/admin/pindah/add_pindah.php @@ -52,35 +52,41 @@ - - Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' - }).then((result) => {if (result.value){ - window.location = 'index.php?page=data-pindah'; - } - })"; - }else{ - echo ""; - }} - //selesai proses simpan data + + Swal.fire({title: 'Tambah Data Berhasil',text: '',icon: 'success',confirmButtonText: 'OK' + }).then((result) => {if (result.value){ + window.location = 'index.php?page=data-pindah'; + } + })"; + }else{ + echo ""; + }} + //selesai proses simpan data diff --git a/admin/pindah/data_pindah.php b/admin/pindah/data_pindah.php index 7540504..b5568c2 100644 --- a/admin/pindah/data_pindah.php +++ b/admin/pindah/data_pindah.php @@ -13,20 +13,21 @@
- - - - - - - - + + + + + + + + + query("SELECT p.id_pend, p.nik, p.nama, d.tgl_pindah, d.alasan, d.id_pindah from + $sql = $koneksi->query("SELECT p.id_pend, p.nik, p.nama, p.jekel, d.tgl_pindah, d.alasan, d.id_pindah from tb_pindah d inner join tb_pdd p on p.id_pend=d.id_pdd"); while ($data= $sql->fetch_assoc()) { ?> @@ -41,9 +42,12 @@ - + + diff --git a/admin/pindah/view_pindah.php b/admin/pindah/view_pindah.php index 973fc57..63c4b5a 100644 --- a/admin/pindah/view_pindah.php +++ b/admin/pindah/view_pindah.php @@ -90,7 +90,15 @@ Jenis Kelamin diff --git a/inc/koneksi.php b/inc/koneksi.php index 1b17aea..8f24438 100644 --- a/inc/koneksi.php +++ b/inc/koneksi.php @@ -10,3 +10,5 @@ if ($koneksi->connect_error) { die("Koneksi database gagal: " . $koneksi->connect_error); } +$koneksi->set_charset("utf8mb4"); + diff --git a/index.php b/index.php index eb29d74..db93091 100644 --- a/index.php +++ b/index.php @@ -389,31 +389,31 @@
NoNIKNamaTanggalAlasanAksi
NoNIKNamaJenis KelaminTanggalAlasanAksi
- - + + + + : - +
: - +
Nama : - +
Jenis Kelamin : - +
Tanggal Datang : - +
-

Benar-benar Telah datang dan berencana untuk tinggal di , , .

+

Benar-benar Telah datang dan berencana untuk tinggal di , , .

Demikian Surat ini dibuat, agar dapat digunakan sebagaimana mestinya.



@@ -92,7 +102,7 @@

- , + ,
KEPALA DESA
@@ -101,7 +111,7 @@


-
() +
()

diff --git a/report/cetak_domisili.php b/report/cetak_domisili.php index ecef3fa..8ba504b 100644 --- a/report/cetak_domisili.php +++ b/report/cetak_domisili.php @@ -1,9 +1,11 @@ Nama
Tgl Lahir UsiaJKJenis Kelamin Alamat
' Thn , RT / RW
: - +
NIK NamaJekelJenis Kelamin Tanggal Datang Pelapor
'
(No KK: ')
' No NIK NamaJKJenis Kelamin Alamat Status
' , RT / RW
'