Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //koneksi dan session
- ini_set("display_errors","off");
- include "../../_Config/Connection.php";
- include "../../_Config/Function.php";
- date_default_timezone_set("Asia/Jakarta");
- //Keyword_by
- if(!empty($_POST['keyword_by'])){
- $keyword_by=$_POST['keyword_by'];
- }else{
- $keyword_by="";
- }
- //keyword
- if(!empty($_POST['keyword'])){
- $keyword=$_POST['keyword'];
- }else{
- $keyword="";
- }
- //batas
- if(!empty($_POST['batas'])){
- $batas=$_POST['batas'];
- }else{
- $batas="10";
- }
- //ShortBy
- if(!empty($_POST['ShortBy'])){
- $ShortBy=$_POST['ShortBy'];
- }else{
- $ShortBy="DESC";
- }
- //OrderBy
- if(!empty($_POST['OrderBy'])){
- $OrderBy=$_POST['OrderBy'];
- }else{
- $OrderBy="id_pasien";
- }
- //Atur Page
- if(!empty($_POST['page'])){
- $page=$_POST['page'];
- $posisi = ( $page - 1 ) * $batas;
- }else{
- $page="1";
- $posisi = 0;
- }
- if(empty($keyword_by)){
- if(empty($keyword)){
- $jml_data = mysqli_num_rows(mysqli_query($Conn, "SELECT*FROM pasien"));
- }else{
- $jml_data = mysqli_num_rows(mysqli_query($Conn, "SELECT*FROM pasien WHERE nama like '%$keyword%' OR nik like '%$keyword%' OR no_bpjs like '%$keyword%' OR kontak like '%$keyword%' OR gender like '%$keyword%' OR alamat like '%$keyword%' OR golongan_darah like '%$keyword%' OR status like '%$keyword%'"));
- }
- }else{
- if(empty($keyword)){
- $jml_data = mysqli_num_rows(mysqli_query($Conn, "SELECT*FROM pasien"));
- }else{
- $jml_data = mysqli_num_rows(mysqli_query($Conn, "SELECT*FROM pasien WHERE $keyword_by like '%$keyword%'"));
- }
- }
- ?>
- <script>
- //ketika klik next
- $('#NextPage').click(function() {
- var valueNext=$('#NextPage').val();
- var batas="<?php echo "$batas"; ?>";
- var keyword="<?php echo "$keyword"; ?>";
- var keyword_by="<?php echo "$keyword_by"; ?>";
- var OrderBy="<?php echo "$OrderBy"; ?>";
- var ShortBy="<?php echo "$ShortBy"; ?>";
- $.ajax({
- url : "_Page/Pasien/TabelPasien.php",
- method : "POST",
- data : { page: valueNext, batas: batas, keyword: keyword, keyword_by: keyword_by, OrderBy: OrderBy, ShortBy: ShortBy },
- success: function (data) {
- $('#MenampilkanTabelPasien').html(data);
- $('#PutPage').val(valueNext);
- }
- })
- });
- //Ketika klik Previous
- $('#PrevPage').click(function() {
- var ValuePrev = $('#PrevPage').val();
- var batas="<?php echo "$batas"; ?>";
- var keyword="<?php echo "$keyword"; ?>";
- var keyword_by="<?php echo "$keyword_by"; ?>";
- var OrderBy="<?php echo "$OrderBy"; ?>";
- var ShortBy="<?php echo "$ShortBy"; ?>";
- $.ajax({
- url : "_Page/Pasien/TabelPasien.php",
- method : "POST",
- data : { page: ValuePrev,batas: batas, keyword: keyword, keyword_by: keyword_by, OrderBy: OrderBy, ShortBy: ShortBy },
- success : function (data) {
- $('#MenampilkanTabelPasien').html(data);
- $('#PutPage').val(ValuePrev);
- }
- })
- });
- <?php
- $JmlHalaman =ceil($jml_data/$batas);
- $a=1;
- $b=$JmlHalaman;
- for ( $i =$a; $i<=$b; $i++ ){
- ?>
- //ketika klik page number
- $('#PageNumber<?php echo $i;?>').click(function() {
- var PageNumber = $('#PageNumber<?php echo $i;?>').val();
- var batas="<?php echo "$batas"; ?>";
- var keyword="<?php echo "$keyword"; ?>";
- var keyword_by="<?php echo "$keyword_by"; ?>";
- var OrderBy="<?php echo "$OrderBy"; ?>";
- var ShortBy="<?php echo "$ShortBy"; ?>";
- $.ajax({
- url : "_Page/Pasien/TabelPasien.php",
- method : "POST",
- data : { page: PageNumber, batas: batas, keyword: keyword, keyword_by: keyword_by, OrderBy: OrderBy, ShortBy: ShortBy },
- success: function (data) {
- $('#MenampilkanTabelPasien').html(data);
- $('#PutPage').val(PageNumber);
- }
- })
- });
- <?php } ?>
- </script>
- <?php
- $no = 1+$posisi;
- if(empty($jml_data)){
- echo '<div class="row">';
- echo ' <div class="col-md-12">';
- echo ' <div class="card">';
- echo ' <div class="card-body text-center text-danger">';
- echo ' Tidak Ada Pasien Yang Ditampilkan';
- echo ' </div>';
- echo ' </div>';
- echo ' </div>';
- echo '</div>';
- }else{
- echo '<div class="row">';
- //KONDISI PENGATURAN MASING FILTER
- if(empty($keyword_by)){
- if(empty($keyword)){
- $query = mysqli_query($Conn, "SELECT*FROM pasien ORDER BY $OrderBy $ShortBy LIMIT $posisi, $batas");
- }else{
- $query = mysqli_query($Conn, "SELECT*FROM pasien WHERE nama like '%$keyword%' OR nik like '%$keyword%' OR no_bpjs like '%$keyword%' OR kontak like '%$keyword%' OR gender like '%$keyword%' OR alamat like '%$keyword%' OR golongan_darah like '%$keyword%' OR status like '%$keyword%' ORDER BY $OrderBy $ShortBy LIMIT $posisi, $batas");
- }
- }else{
- if(empty($keyword)){
- $query = mysqli_query($Conn, "SELECT*FROM pasien ORDER BY $OrderBy $ShortBy LIMIT $posisi, $batas");
- }else{
- $query = mysqli_query($Conn, "SELECT*FROM pasien WHERE $keyword_by like '%$keyword%' ORDER BY $OrderBy $ShortBy LIMIT $posisi, $batas");
- }
- }
- while ($data = mysqli_fetch_array($query)) {
- $id_pasien= $data['id_pasien'];
- $nama= $data['nama'];
- $nik= $data['nik'];
- $no_bpjs= $data['no_bpjs'];
- $kontak= $data['kontak'];
- $tempat_lahir= $data['tempat_lahir'];
- $tanggal_lahir= $data['tanggal_lahir'];
- $gender= $data['gender'];
- $provinsi= $data['provinsi'];
- $kabupaten= $data['kabupaten'];
- $kecamatan= $data['kecamatan'];
- $desa= $data['desa'];
- $golongan_darah= $data['golongan_darah'];
- $status= $data['status'];
- $tanggal_daftar= $data['tanggal_daftar'];
- $TanggalDaftar=FormatDateTime('d/m/Y H:i:s',$tanggal_daftar);
- ?>
- <div class="col-md-6 mb-2">
- <div class="card">
- <div class="card-header">
- <a href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#ModalDetailPasien" data-id="<?php echo "$id_pasien";?>">
- <b><?php echo "$no. $nama";?></b>
- </a>
- <div class="filter">
- <a class="icon" href="#" data-bs-toggle="dropdown" aria-expanded="false"><i class="bi bi-three-dots"></i></a>
- <ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow" style="">
- <li class="dropdown-header text-start">
- <h6>Option</h6>
- </li>
- <li>
- <a href="javascript:void(0);" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#ModalDetailPasien" data-id="<?php echo "$id_pasien"; ?>">
- <i class="bi bi-info-circle"></i> Detail
- </a>
- </li>
- <li>
- <a href="javascript:void(0);" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#ModalEditPasien" data-id="<?php echo "$id_pasien"; ?>">
- <i class="bi bi-pencil-square"></i> Edit
- </a>
- </li>
- <li>
- <a href="javascript:void(0);" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#ModalHapusPasien" data-id="<?php echo "$id_pasien"; ?>">
- <i class="bi bi-trash"></i> Hapus
- </a>
- </li>
- </ul>
- </div>
- </div>
- <div class="card-body">
- <div class="row">
- <div class="col-md-12">
- <small>
- <i class="bi bi-info-circle"></i> No.RM: <code class="text-secondary"><?php echo "$id_pasien"; ?></code><br>
- <i class="bi bi-person-badge"></i> NIK:
- <a href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#ModalDetailNik" data-id="<?php echo "$nik"; ?>">
- <code class="text-info"><?php echo "$nik"; ?> <i class="bi bi-arrow-up-right-circle"></i></code>
- </a>
- <br>
- <i class="bi bi-person-badge"></i> BPJS:
- <a href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#ModalDetailBpjs" data-id="<?php echo "$no_bpjs"; ?>">
- <code class="text-info"><?php echo "$no_bpjs"; ?> <i class="bi bi-arrow-up-right-circle"></i></code>
- </a>
- <br>
- <i class="bi bi-calendar"></i> Tgl: <code class="text-secondary"><?php echo "$TanggalDaftar"; ?></code><br>
- </small>
- </div>
- </div>
- </div>
- </div>
- </div>
- <?php
- $no++;
- }
- echo '</div>';
- }
- ?>
- <div class="row">
- <div class="col-md-12 text-center">
- <div class="btn-group shadow-0" role="group" aria-label="Basic example">
- <?php
- //Mengatur Halaman
- $JmlHalaman = ceil($jml_data/$batas);
- $JmlHalaman_real = ceil($jml_data/$batas);
- $prev=$page-1;
- $next=$page+1;
- if($next>$JmlHalaman){
- $next=$page;
- }else{
- $next=$page+1;
- }
- if($prev<"1"){
- $prev="1";
- }else{
- $prev=$page-1;
- }
- ?>
- <button class="btn btn-sm btn-outline-info" id="PrevPage" value="<?php echo $prev;?>">
- <span aria-hidden="true">«</span>
- </button>
- <?php
- //Navigasi nomor
- if($JmlHalaman>3){
- if($page>=2){
- $a=$page-1;
- $b=$page+1;
- if($JmlHalaman<=$b){
- $a=$page-1;
- $b=$JmlHalaman;
- }
- }else{
- $a=1;
- $b=$page+1;
- if($JmlHalaman<=$b){
- $a=1;
- $b=$JmlHalaman;
- }
- }
- }else{
- $a=1;
- $b=$JmlHalaman;
- }
- for ( $i =$a; $i<=$b; $i++ ){
- if($page=="$i"){
- echo '<button class="btn btn-sm btn-info" id="PageNumber'.$i.'" value="'.$i.'"><span aria-hidden="true">'.$i.'</span></button>';
- }else{
- echo '<button class="btn btn-sm btn-outline-info" id="PageNumber'.$i.'" value="'.$i.'"><span aria-hidden="true">'.$i.'</span></button>';
- }
- }
- ?>
- <button class="btn btn-sm btn-outline-info" id="NextPage" value="<?php echo $next;?>">
- <span aria-hidden="true">»</span>
- </button>
- </div>
- </div>
- </div>
Add Comment
Please, Sign In to add comment