MINI
C:
/
siak
/
app
/
AdminLTE
/
Upload File:
files >> C:/siak/app/AdminLTE/pencarian - Copy.php
<?php // =========================================================== // KONEKSI DATABASE SIAK // =========================================================== $ipektp = '10.65.0.3'; $portdbsiak = '1521'; $dbsiakuser = 'SIAKOFF'; $dbsiakpwd = 'bobbytgs13'; $dbsiaksid = 'SIAKDB'; $conn_siak = oci_connect($dbsiakuser, $dbsiakpwd, "$ipektp:$portdbsiak/$dbsiaksid"); oci_execute(oci_parse($conn_siak, "ALTER SESSION SET nls_date_format='DD-MM-YYYY'")); $listdata = []; // hasil list $result = null; // hasil detail $pengikut = []; $error = null; $modeCari = null; // =========================================================== // PROSES CARI NIK // =========================================================== if (!empty($_POST['nik_siak'])) { $modeCari = "nik"; $nik = trim($_POST['nik_siak']); $query = "SELECT NIK, NO_KK, NAMA_LGKP, JENIS_KLMIN, TMPT_LHR, TGL_LHR FROM biodata_wni WHERE NIK = :nik"; $st = oci_parse($conn_siak, $query); oci_bind_by_name($st, ':nik', $nik); oci_execute($st); $row = oci_fetch_assoc($st); if ($row) { $row['JENIS_KLMIN'] = ($row['JENIS_KLMIN'] == 1 ? "Laki-Laki" : "Perempuan"); $result = $row; // Ambil anggota KK $nokk = $row['NO_KK']; $sql = "SELECT NIK, NAMA_LGKP, JENIS_KLMIN, TMPT_LHR, TGL_LHR FROM biodata_wni WHERE NO_KK = :kk ORDER BY NAMA_LGKP"; $st2 = oci_parse($conn_siak, $sql); oci_bind_by_name($st2, ':kk', $nokk); oci_execute($st2); while ($r = oci_fetch_assoc($st2)) { $r['JENIS_KLMIN'] = ($r['JENIS_KLMIN']==1?"Laki-Laki":"Perempuan"); $pengikut[] = $r; } } else { $error = "NIK tidak ditemukan!"; } } // =========================================================== // PROSES CARI NAMA // =========================================================== if (!empty($_POST['nama_siak'])) { $modeCari = "nama"; $nama = strtoupper(trim($_POST['nama_siak'])); $query = "SELECT NIK, NO_KK, NAMA_LGKP, JENIS_KLMIN, TMPT_LHR, TGL_LHR FROM biodata_wni WHERE UPPER(NAMA_LGKP) LIKE '%' || :nama || '%' ORDER BY NAMA_LGKP"; $st = oci_parse($conn_siak, $query); oci_bind_by_name($st, ':nama', $nama); oci_execute($st); while ($d = oci_fetch_assoc($st)) { $d['JENIS_KLMIN'] = ($d['JENIS_KLMIN']==1?"Laki-Laki":"Perempuan"); $listdata[] = $d; } if (empty($listdata)) $error = "Nama tidak ditemukan!"; if (count($listdata)==1) $result = $listdata[0]; } // =========================================================== // PROSES CARI NOMOR KK // =========================================================== if (!empty($_POST['nokk_siak'])) { $modeCari = "nokk"; $kk = trim($_POST['nokk_siak']); $query = "SELECT NIK, NO_KK, NAMA_LGKP, JENIS_KLMIN, TMPT_LHR, TGL_LHR FROM biodata_wni WHERE NO_KK = :kk ORDER BY NAMA_LGKP"; $st = oci_parse($conn_siak, $query); oci_bind_by_name($st, ':kk', $kk); oci_execute($st); while ($d = oci_fetch_assoc($st)) { $d['JENIS_KLMIN'] = ($d['JENIS_KLMIN']==1?"Laki-Laki":"Perempuan"); $listdata[] = $d; } if (empty($listdata)) $error = "Nomor KK tidak ditemukan!"; } // =========================================================== // PROSES CARI TEMPAT LAHIR // =========================================================== if (!empty($_POST['tmplahir_siak'])) { $modeCari = "tmplahir"; $tempat = strtoupper(trim($_POST['tmplahir_siak'])); $query = "SELECT NIK, NO_KK, NAMA_LGKP, JENIS_KLMIN, TMPT_LHR, TGL_LHR FROM biodata_wni WHERE UPPER(TMPT_LHR) LIKE '%' || :tmp || '%' ORDER BY TGL_LHR DESC"; $st = oci_parse($conn_siak, $query); oci_bind_by_name($st, ':tmp', $tempat); oci_execute($st); while ($d = oci_fetch_assoc($st)) { $d['JENIS_KLMIN'] = ($d['JENIS_KLMIN']==1?"Laki-Laki":"Perempuan"); $listdata[] = $d; } if (empty($listdata)) $error = "Tidak ada penduduk dengan tempat lahir tersebut!"; } // =========================================================== // PROSES CARI TANGGAL LAHIR // =========================================================== if (!empty($_POST['tgll1']) && !empty($_POST['tgll2'])) { $modeCari = "tgllahir"; $tgl1 = $_POST['tgll1']; $tgl2 = $_POST['tgll2']; $query = "SELECT NIK, NO_KK, NAMA_LGKP, JENIS_KLMIN, TMPT_LHR, TGL_LHR FROM biodata_wni WHERE TGL_LHR BETWEEN TO_DATE(:t1,'YYYY-MM-DD') AND TO_DATE(:t2,'YYYY-MM-DD') ORDER BY TGL_LHR"; $st = oci_parse($conn_siak, $query); oci_bind_by_name($st, ':t1', $tgl1); oci_bind_by_name($st, ':t2', $tgl2); oci_execute($st); while ($d = oci_fetch_assoc($st)) { $d['JENIS_KLMIN'] = ($d['JENIS_KLMIN']==1?"Laki-Laki":"Perempuan"); $listdata[] = $d; } if (empty($listdata)) $error = "Tidak ada data dalam rentang tanggal tersebut!"; } ?> <!-- =========================================================== FORM PENCARIAN =========================================================== --> <form method="POST" class="mb-4"> <h5><b>Pencarian Biodata SIAK</b></h5> <input type="text" name="nik_siak" class="form-control mb-1" placeholder="Cari berdasarkan NIK"> <input type="text" name="nama_siak" class="form-control mb-1" placeholder="Cari berdasarkan Nama"> <input type="text" name="nokk_siak" class="form-control mb-1" placeholder="Cari berdasarkan Nomor KK"> <input type="text" name="tmplahir_siak" class="form-control mb-1" placeholder="Cari berdasarkan Tempat Lahir"> <label>Rentang Tanggal Lahir:</label> <div class="row"> <div class="col"> <input type="date" name="tgll1" class="form-control mb-1"> </div> <div class="col"> <input type="date" name="tgll2" class="form-control mb-1"> </div> </div> <button class="btn btn-primary mt-2">Cari Data</button> </form> <?php if ($error): ?> <div class="alert alert-danger"><?= $error ?></div> <?php endif; ?> <!-- =========================================================== TAMPILAN LIST (MULTI HASIL) =========================================================== --> <?php if ($listdata && !$result): ?> <h4 class="text-center">Hasil Pencarian</h4> <table class="table table-bordered table-striped"> <tr> <th>NIK</th> <th>Nama</th> <th>JK</th> <th>Lahir</th> <th>Aksi</th> </tr> <?php foreach ($listdata as $p): ?> <tr> <td><?= $p['NIK'] ?></td> <td><?= $p['NAMA_LGKP'] ?></td> <td><?= $p['JENIS_KLMIN'] ?></td> <td><?= $p['TMPT_LHR'] ?>, <?= $p['TGL_LHR'] ?></td> <td> <form method="POST"> <input type="hidden" name="nik_siak" value="<?= $p['NIK'] ?>"> <button class="btn btn-info btn-sm">Lihat Detail</button> </form> </td> </tr> <?php endforeach; ?> </table> <?php endif; ?> <!-- =========================================================== TAMPILAN DETAIL (1 ORANG) =========================================================== --> <?php if ($result): ?> <h4 class="text-center">Detail Biodata SIAK</h4> <table class="table table-bordered"> <tr><th>NIK</th><td><?= $result['NIK'] ?></td></tr> <tr><th>No KK</th><td><?= $result['NO_KK'] ?></td></tr> <tr><th>Nama</th><td><?= $result['NAMA_LGKP'] ?></td></tr> <tr><th>Jenis Kelamin</th><td><?= $result['JENIS_KLMIN'] ?></td></tr> <tr><th>Tempat/Tanggal Lahir</th><td><?= $result['TMPT_LHR'] ?>, <?= $result['TGL_LHR'] ?></td></tr> </table> <h4 class="text-center mt-4">Anggota Dalam KK</h4> <table class="table table-striped"> <tr><th>NIK</th><th>Nama</th><th>JK</th><th>Lahir</th></tr> <?php foreach ($pengikut as $p): ?> <tr> <td><?= $p['NIK'] ?></td> <td><?= $p['NAMA_LGKP'] ?></td> <td><?= $p['JENIS_KLMIN'] ?></td> <td><?= $p['TMPT_LHR'] ?>, <?= $p['TGL_LHR'] ?></td> </tr> <?php endforeach; ?> </table> <?php endif; ?>
Copyright ©2021 || Defacer Indonesia