Rabu, 10 Juli 2019

APLIKASI PEMBAYARAN LISTRIK PASCA BAYAR MELALUI PPOB (Payment Point Online Bank)


LAPORAN MODUL
SISTEM APLIKASI PEMBAYARAN LISTRIK PASCA BAYAR MELALUI PPOB (Payment Point Online Bank)



  




Disusun oleh :
ERAWATI SETYA NINGRUM




SMK SATYA PRAJA 2 PETARUKAN
REKAYASA PERANGKAT LUNAK
TAHUN PELAJARAN 2018/2019






Kata Pengantar

Modul ini dibuat untuk menjadi panduan dalam membuat aplikasi sederhana menggunakan bahasa pemrograman berbasis web dengan PHP, dan database MySQL. Dalam modul ini berisikan :

1.                              Perancangan Flowchart
2.                              Pembuatan Database
3.                              Login
4.                              Logout
5.                              Registrasi
6.                              Pengolahan Data Pelanggan
7.                              Verifikasi Dan Validasi
8.                              Pembayaran
9.                              Generate Laporan

Semoga modul ini bisa menjadi pengingat untuk teman-teman dalam membuat dasar darisebuah web menggunakan PHP dan MySQL. Dari fundamental yang sudah ada, dapat dibuataplikasi yang lebih kompleks sesuai dengan kebutuhan.

1.      Gambar Perancangan Flowchart :


DATABASE

2.      Pembuatan Database
1.      Pertama kita buat databasenya terlebih dahulu,disini saya menggunakan XAMPP,Ketik di browser alamat http://localhost/phpmyadmin
2.      Setelah masuk Selanjutnya buat database “db_listrik”,selanjutnya buat tabel admin, pelanggan, pembayaran, tagihan,tarif.
*Tabel admin :
CREATE TABLE IF NOT EXISTS `admin` (
  `username` varchar(30) NOT NULL,
  `password` varchar(30) NOT NULL,
  `nama_admin` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
*Tabel pelanggan
CREATE TABLE IF NOT EXISTS `pelanggan` (
  `id_pelanggan` varchar(30) NOT NULL,
  `username` varchar(30) NOT NULL,
  `password` varchar(30) NOT NULL,
  `nama_pelanggan` varchar(100) NOT NULL,
  `alamat` text NOT NULL,
  `id_tarif` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
*Tabel pembayaran
CREATE TABLE IF NOT EXISTS `pembayaran` (
  `id_pembayaran` varchar(30) NOT NULL,
  `id_tagihan` varchar(30) NOT NULL,
  `id_pelanggan` varchar(30) NOT NULL,
  `bulan` varchar(30) NOT NULL,
  `tahun` varchar(30) NOT NULL,
  `metode` varchar(100) NOT NULL,
  `bukti` varchar(100) NOT NULL,
  `tgl_bayar` varchar(100) NOT NULL,
  `biaya` varchar(30) NOT NULL,
  `status` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
*Tabel tagihan
CREATE TABLE IF NOT EXISTS `tagihan` (
  `id_tagihan` varchar(30) NOT NULL,
  `id_pelanggan` varchar(30) NOT NULL,
  `bulan` varchar(100) NOT NULL,
  `tahun` varchar(100) NOT NULL,
  `jumlah_meter` varchar(100) NOT NULL,
  `biaya` varchar(30) NOT NULL,
  `status` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
*Tabel tarif
CREATE TABLE IF NOT EXISTS `tarif` (
  `id_tarif` varchar(30) NOT NULL,
  `daya` varchar(100) NOT NULL,
  `tarifperkwh` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

HYPERTEXT MARKUP LANGUAGE (HTML)

3.      Penulisan Script

1.      Kita buat script Koneksinya terlebih dahulu dengan buat foldel nama upk_erawati/data/..seperti berikut:

·         Config.php

 

<?php

error_reporting(0);

include "koneksi.php";

include "database.php";

include "db_admin.php";

include "db_pelanggan.php";

include "db_pembayaran.php";

include "db_tagihan.php";

include "db_tarif.php";

include "fungsi.php";

 

·         database.php

 

<?php

function create($table="", $data="", $values=""){

      $create = mysql_query("INSERT INTO $table($data)VALUES($values)");

      return $create;

}

function read($table="", $add=""){

      if(!empty($add)){

                  $read = mysql_query("SELECT*FROM $table $add");

      }else{

                  $read = mysql_query("SELECT*FROM $table");

      }

      return $read;

}

function update($table="", $set="", $where=""){

      $update = mysql_query("UPDATE $table SET $set WHERE $where");

      return $update;

}

function delete($table="", $where=""){

      $delete = mysql_query("DELETE FROM $table WHERE $where");

      return $delete;

}

 

·         fungsi.php

 

<?php

function rupiah($angka){

                  $hasil_rupiah = "Rp " . number_format($angka,2,',','.');

      return $hasil_rupiah;

}

 

·         koneksi.php

 

<?php

$host = "localhost";

$user = "root";

$pass = "";

$db   = "db_listrik";

mysql_connect($host, $user, $pass);

mysql_select_db($db);

?>

 

 

 

·         db_admin.php

 

<?php

function tambah_admin($username="", $password="", $nama_admin=""){

      $data = "username,password,nama_admin";

      $values = "'$username', '$password', '$nama_admin'";

      $tambah_admin = create("admin", $data, $values);

      return $tambah_admin;

}

function lihat_admin(){

      $tabel = read("admin");

      while($query = mysql_fetch_assoc($tabel)){

                              $lihat_admin[] = $query;

      }

      return $lihat_admin;

}

function pilih_admin($username=""){

      $where = "WHERE username='$username'";

      $tabel = read("admin", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $pilih_admin[] = $query;

      }

      return $pilih_admin;

}

function update_admin($username="", $password="", $nama_admin=""){

      $where = "username='$username'";

      $set = "password='$password', nama_admin='$nama_admin'";

      $update_admin = update("admin", $set, $where);

      return $update_admin;

}

function hapus_admin($username=""){

      $where = "username='$username'";

      $hapus_admin = delete("admin", $where);

      return $hapus_admin;

}

// login

function cek_admin($username="", $password=""){

      $where = "WHERE username='$username' AND password='$password'";

      $query = read("admin", $where);

      $cek_admin = mysql_num_rows($query);

      return $cek_admin;

}

function login_admin($username="", $password=""){

      $where = "WHERE username='$username' AND password='$password'";

      $tabel = read("admin", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $login_admin[] = $query;

      }

      return $login_admin;

}

 

 

 

 

·         db_pelanggan.php

 

<?php

function tambah_pelanggan($id_pelanggan, $username, $password, $nama_pelanggan, $alamat, $id_tarif){

      $data = "id_pelanggan, username, password, nama_pelanggan, alamat, id_tarif";

      $values = "'$id_pelanggan', '$username', '$password', '$nama_pelanggan', '$alamat', '$id_tarif'";

      $tambah_pelanggan = create("pelanggan", $data, $values);

      return $tambah_pelanggan;

}

function lihat_pelanggan(){

      $tabel  =  read("pelanggan");

      while ($query = mysql_fetch_assoc($tabel)) {

                  $lihat_pelanggan[] = $query;

      }

      return $lihat_pelanggan;

}

function pilih_pelanggan($id_pelanggan=""){

      $where = "WHERE id_pelanggan='$id_pelanggan'";

      $tabel = read("pelanggan", $where);

      while($query = mysql_fetch_assoc($tabel)){

                  $pilih_pelanggan[] = $query;

}

return $pilih_pelanggan;

}

function update_pelanggan($id_pelanggan="", $username="", $password="", $nama_pelanggan="", $alamat="", $id_tarif=""){

      $where = "id_pelanggan='$id_pelanggan'";

      $set = "username='$username', password='$password', nama_pelanggan='$nama_pelanggan', alamat='$alamat',  id_tarif='$id_tarif'";

      $update_pelanggan = update("pelanggan", $set, $where);

      return $update_pelanggan;

}

function hapus_pelanggan($id_pelanggan=""){

      $where = "id_pelanggan='$id_pelanggan'";

      $hapus_pelanggan = delete("pelanggan", $where);

      return $hapus_pelanggan;

}

//  id

function id_pelanggan(){

$carikode = mysql_query("SELECT id_pelanggan from pelanggan");

  $datakode = mysql_fetch_array($carikode);

  $jumlah_data = mysql_num_rows($carikode);

if($datakode) {

   $nilaikode = substr($jumlah_data[0], 1);

   $kode = (int) $nilaikode;

   $kode = $jumlah_data + 1;

   $id_pelanggan = "PLG".str_pad($kode, 3, "0", STR_PAD_LEFT);

}else{

   $id_pelanggan = "PLG001";

}

return $id_pelanggan;

}

// login

function cek_pelanggan($username="", $password=""){

      $where = "WHERE username='$username' AND password='$password'";

      $query = read("pelanggan", $where);

      $cek_pelanggan = mysql_num_rows($query);

      return $cek_pelanggan;

}

function login_pelanggan($username="", $password=""){

      $where = "WHERE username='$username' AND password='$password'";

      $tabel = read("pelanggan", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $login_pelanggan[] = $query;

      }

      return $login_pelanggan;

}

 

·         db_pembayaran.php

 

<?php

function tambah_pembayaran($id_pembayaran="", $id_tagihan="", $id_pelanggan="", $bulan="", $tahun="", $metode="", $bukti="", $tgl_bayar="", $biaya="", $status=""){

      $data = "id_pembayaran, id_tagihan, id_pelanggan, bulan, tahun, metode, bukti, tgl_bayar, biaya, status";

      $values = "'$id_pembayaran', '$id_tagihan', '$id_pelanggan', '$bulan', '$tahun', '$metode', '$bukti' ,'$tgl_bayar', '$biaya', '$status'";

      $tambah_pembayaran = create("pembayaran", $data, $values);

      return $tambah_pembayaran;

}

function lihat_pembayaran(){

      $tabel = read("pembayaran");

      while($query = mysql_fetch_assoc($tabel)){

                              $lihat_pembayaran[] = $query;

      }

      return $lihat_pembayaran;

}

function pilih_pembayaran($id_pembayaran=""){

      $where = "WHERE id_pembayaran='$id_pembayaran'";

      $tabel = read("pembayaran", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $pilih_pembayaran[] = $query;

      }

      return $pilih_pembayaran;

}

function update_pembayaran($id_pembayaran="", $status=""){

      $where = "id_pembayaran='$id_pembayaran'";

      $set = "status='$status'";

      $update_pembayaran = update("pembayaran", $set, $where);

      return $update_pembayaran;

}

function hapus_pembayaran($id_pembayaran=""){

      $where = "id_pembayaran='$id_pembayaran'";

      $hapus_pembayaran = delete("pembayaran", $where);

      return $hapus_pembayaran;

}

// id pembayaran

function id_pembayaran(){

$carikode = mysql_query("SELECT id_pembayaran from pembayaran");

  $datakode = mysql_fetch_array($carikode);

  $jumlah_data = mysql_num_rows($carikode);

if($datakode) {

   $nilaikode = substr($jumlah_data[0], 1);

   $kode = (int) $nilaikode;

   $kode = $jumlah_data + 1;

   $id_pembayaran = "BYR".str_pad($kode, 3, "0", STR_PAD_LEFT);

}else{

   $id_pembayaran = "BYR001";

}

return $id_pembayaran;

}

// pelanggan

function pelanggan_pembayaran($id_pelanggan=""){

      $where = "WHERE id_pelanggan='$id_pelanggan'";

      $tabel = read("pembayaran", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $pelanggan_pembayaran[] = $query;

      }

      return $pelanggan_pembayaran;

}

 

·         db_tagihan.php

 

<?php

function tambah_tagihan($id_tagihan="", $id_pelanggan="", $bulan="", $tahun="", $jumlah_meter="", $biaya="", $status=""){

      $data = "id_tagihan, id_pelanggan, bulan, tahun, jumlah_meter, biaya, status";

      $values = "'$id_tagihan', '$id_pelanggan', '$bulan', '$tahun', '$jumlah_meter','$biaya', '$status'";

      $tambah_tagihan = create("tagihan", $data, $values);

      return $tambah_tagihan;

}

function lihat_tagihan(){

      $tabel = read("tagihan");

      while($query = mysql_fetch_assoc($tabel)){

                              $lihat_tagihan[] = $query;

      }

      return $lihat_tagihan;

}

function pilih_tagihan($id_tagihan=""){

      $where = "WHERE id_tagihan='$id_tagihan'";

      $tabel = read("tagihan", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $pilih_tagihan[] = $query;

      }

      return $pilih_tagihan;

}

function update_tagihan($id_tagihan=""){

      $where = "id_tagihan='$id_tagihan'";

      $set = "status='Bayar'";

      $update_tagihan = update("tagihan", $set, $where);

      return $update_tagihan;

}

function hapus_tagihan($id_tagihan=""){

      $where = "id_tagihan='$id_tagihan'";

      $hapus_tagihan = delete("tagihan", $where);

      return $hapus_tagihan;

}

//  id

function id_tagihan(){

$carikode = mysql_query("SELECT id_tagihan from tagihan");

  $datakode = mysql_fetch_array($carikode);

  $jumlah_data = mysql_num_rows($carikode);

if($datakode) {

   $nilaikode = substr($jumlah_data[0], 1);

   $kode = (int) $nilaikode;

   $kode = $jumlah_data + 1;

   $id_tagihan = "TGH".str_pad($kode, 3, "0", STR_PAD_LEFT);

}else{

   $id_tagihan = "TGH001";

}

return $id_tagihan;

}

// pelanggan

function pelanggan_tagihan($id_pelanggan=""){

      $where = "WHERE id_pelanggan='$id_pelanggan'";

      $tabel = read("tagihan", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $pelanggan_tagihan[] = $query;

      }

      return $pelanggan_tagihan;

}

 

·         db_tarif.php

 

<?php

function tambah_tarif($id_tarif="", $daya="", $tarifperkwh=""){

      $data = "id_tarif, daya, tarifperkwh";

      $value = "'$id_tarif', '$daya', '$tarifperkwh'";

      $tambah_tarif = create("tarif", $data, $value);

      return $tambah_tarif;

}

 

function lihat_tarif(){

      $tabel = read("tarif");

      while($query = mysql_fetch_assoc($tabel)){

                              $lihat_tarif[] = $query;

      }

      return $lihat_tarif;

}

function pilih_tarif($id_tarif=""){

      $where = "WHERE id_tarif='$id_tarif'";

      $tabel = read("tarif", $where);

      while($query = mysql_fetch_assoc($tabel)){

                              $pilih_tarif[] = $query;

      }

      return $pilih_tarif;

}

function update_tarif($id_tarif="", $daya="", $tarifperkwh=""){

      $where = "id_tarif='$id_tarif'";

      $set = "daya='$daya', tarifperkwh='$tarifperkwh'";

      $update_admin = update("tarif", $set, $where);

      return $update_admin;

}

function hapus_tarif($id_tarif=""){

      $where = "id_tarif='$id_tarif'";

      $hapus_tarif = delete("tarif", $where);

      return $hapus_tarif;

}

//  id

function id_tarif(){

$carikode = mysql_query("SELECT id_tarif from tarif");

  $datakode = mysql_fetch_array($carikode);

  $jumlah_data = mysql_num_rows($carikode);

if($datakode) {

   $nilaikode = substr($jumlah_data[0], 1);

   $kode = (int) $nilaikode;

   $kode = $jumlah_data + 1;

   $id_tarif = "TRF".str_pad($kode, 3, "0", STR_PAD_LEFT);

}else{

   $id_tarif = "TRF001";

}

return $id_tarif;

}

 

 

2.      Kita buat folder didengan nama admin dengan cara klik New Folder pada C:xampp/htdocs/upk_erawati/admin/... seperti berikut :
3.      Mari kita buat script login masuk.php untuk Admin seperti berikut :
<html>
<head>
            <title>Form Login</title>
<link rel="stylesheet" type="text/css" href="../assets/template/style.css">
<link rel="stylesheet" type="text/css" href="../assets/template/masuk.css">
</head>
<body>
<div id="formWrapper">
<div id="form">
<div class="logo">
            <h1>LOGIN ADMIN</h1>
</div>
<form action="" method="post">
                        <div class="form-item">
                                    <input type="text" name="username" placeholder="Masukan Nama Pengguna" class="form-style" />
                        </div>
                        <div class="form-item">
                                    <input type="password" name="password" placeholder="Masukan Katasandi" class="form-style" />
                                    </div>
                        <div class="form-item">
                        <input type="submit" class="button biru pull-right" name="masuk" value="Masuk">
                        <div class="clear-fix"></div>
                        </div>
</form>
</div>
</div>
</body>
</html>

<?php
session_start();
include "../data/config.php";
if(isset($_POST['masuk'])){
            $user = $_POST['username'];
            $pass = ($_POST['password']);
            $cek = cek_admin($user, $pass);
            if($cek){
                        foreach(login_admin($user, $pass) as $login){
                                    $_SESSION['username_admin'] = $login['username'];
                                    $_SESSION['password_admin'] = $login['password'];
                        }
                        echo "<script>alert('Anda Berhasil Login'); document.location='index.php?modal=beranda'</script>";
            }else{
                        echo "Username Atau Password Salah";
            }
}

4.      Kita buat script Login Pelanggan. Kita simpan pada C:xampp/htdocs/upk_erawati/.. Berikut script masuk.php :
<html>
<head>
            <title>Form Login</title>
<link rel="stylesheet" type="text/css" href="assets/template/style.css">
<link rel="stylesheet" type="text/css" href="assets/template/masuk.css">
</head>
<body>
<div id="formWrapper">
<div id="form">
<div class="logo">
            <h1 align="center">LOGIN PELANGGAN</h1>
</div>
<form action="" method="post">
                        <div class="form-item">
                                    <input type="text" name="username" placeholder="Masukan Nama Pengguna" class="form-style" />
                        </div>
                        <div class="form-item">
                                    <input type="password" name="password" placeholder="Masukan Katasandi" class="form-style" />
                                    </div>
                        <div class="form-item">
                        <p class="pull-left"><a href="index.php"><small>Beranda</small></a></p>
                        <input type="submit" class="button biru pull-right" name="masuk" value="Masuk">
                        <div class="clear-fix"></div>
                        </div>
</form>
</div>
</div>
</body>
</html>
<?php
session_start();
include "data/config.php";
if(isset($_POST['masuk'])){
            $user = $_POST['username'];
            $pass = base64_encode($_POST['password']);
            $cek = cek_pelanggan($user, $pass);
            if($cek){
                        foreach(login_pelanggan($user, $pass) as $login){
                                    $_SESSION['id_pelanggan'] = $login['id_pelanggan'];
                                    $_SESSION['user'] = $login['username'];
                                    $_SESSION['pass'] = $login['password'];
                        }
                        echo "<script>alert('Selamat Datang'); document.location='header.php'</script>";
            }else{
                        echo "Username Atau Password Salah";
            }
}

5.      Agar tampilan lebiih menarik saya tambahkan CSS. Buat folder template pada localdiskC:/xampp/htdocs/upk_erawati/assets/template/..seperti berikut :
·         Berikut script masuk.css dan style.css.
Masuk.css
body{
  background: url(../img/background.jpeg) no-repeat center center fixed;
  background-size: cover;
}
a{text-decoration: none;}
.pull-right{float: right;}
.pull-left{float: left;}
.clear-fix{clear:both;}
div#form{
            position: absolute;
            width:360px;
            height:320px;
            height:auto;
            background-color: #fff;
            margin:auto;
            border-radius: 5px;
            padding:20px;
            left:50%;
            top:50%;
            margin-left:-180px;
            margin-top:-200px;
}
div.form-item{position: relative; display: block; margin-bottom: 20px;}
 .form-style,  .select{
            color:#8a8a8a;
            display: block;
            width: 90%;
            height: 44px;
            padding: 5px 5%;
            border:1px solid #ccc;
            border-radius: 27px;
            font-size: 16px;
}
.select{
            height: 100px;
}

·         Dan berikut script style.css
html {
  font-family: sans-serif;
}
body {
  margin: 0;
}
/*  input   */
.input, .select {
  width: 100%;
  padding: 12px 20px;
  margin: 8px 0;
  display: inline-block;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}
/*  input */
/*  tabel   */
.tabel{
  border-collapse: collapse;
}
.tabel, td, th {
  border: 1px solid #ddd;
  text-align: left;
}
.tabel th, td {
  padding: 15px;
}
/*  tabel   */
/*  button  */
.button {
  border: none;
  color: white;
  padding: 7px 15px;
  border-radius: 5px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
}
.merah{
  background-color: #f00;
}
.hijau{
  background-color: #0f0;
}
.biru{
  background-color: #00f;
}
/*  button  */
.navbar{
  position: relative;
  min-height: 50px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}
.navbar-brand {
  float: left;
  height: 50px;
  padding: 15px 15px;
  font-size: 18px;
  line-height: 20px;
  text-decoration: none;
  color: #000;
}
.navbar-default {
  background-color: #f8f8f8;
  border-color: #e7e7e7;
}
.img{
    width: 25%;
    height: 250px;
    border-radius: 50%;
    border: 2px solid #000;
}
·         Maka hasilnya akan seperti ini :
Halaman Login Admin
Halaman Login Pelanggan
6.      Selanjutnya kita buat Halaman index awal dan Halaman index Admin.
Untuk Halaman index awal kita simpan pada C:/xampp/htdocs/upk_erawati/index.php dan untuk simpan Halaman index Admin kita letakan pada C:/xampp/htdocs/upk_erawati/admin/index.php.
berikut script index.php Halaman Awal   :
<?php 
include "data/config.php";
?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Halaman Index</title>
<style>
.header{
            position:fixed;
            width:100%;
            height:60px;
            padding:10px;
            background:#2980b9;
            margin-top:-140px;
            margin-left:-10px;
            z-index:9999;
            margin-bottom:50px;
            }
.menu{
            width:1000px;
            height:350px;
            border-radius:10px;
            background-color:rgba(255,255,255,1);
            border:solid 1px #999;
            margin-top:80px;
            }
#logo{
            width:150px;
            height:150px;
            background:rgba(204,204,204,0.4);
            border-radius:100px;
            margin-left:140px;
            margin-top:20px;
            margin-right:0px;
            float:left;
            position:relative;
            transition:all ease-in-out 0.5s;
            }
#logo:hover{
            display:block;
            background:rgba(153,153,153,1);
            }
.logo{
            width:60px;height:60px;position:absolute;
            transition:all ease-in-out 1s;
            }
.logo:hover{
            transform:rotate(360deg);
            }
.btn-warning{
            color:#fff;
            background-color:#f0ad4e;
            border-color:#eea236;
            transition:all ease-in-out 0.15s;
            float:right;
             margin-right:50px;
             font-size:18px;
              text-decoration:none;
              border-radius:2px;
              margin-top:-75px;
               padding:4px;
               z-index:99999;
               position:relative;
               width:60px;
}
.btn-warning:hover{
            background-color:rgba(255,204,102,1);
}
a{
            color:#006699;
            font-family:Calibri;
            }
</style>
</head>
<body>
<div class="header">
            <img src="assets/img/1.jpg" class="logo"/>
            <h2 style="font-size:46px;position:relative;margin-left:90px;margin-top:-0px;color:#f0f0f0;text-decoration:none;line-height:   60px;font-family:Calibri;">Pembayaran Listrik Pasca Bayar</h2>
            <a href="../logout.php"><div class="btn-warning">Log out</div></a>
</div>
            <h3 style="position:relative; margin-top:140px;text-align:center;font-family:Calibri;color:#2980b9;">Selamat datang di datang para customer dipembayaran listrik pasca bayar</h3>
<div align="center"><div class="menu">
            <a href="masuk.php"><div id="logo"><img src="assets/img/distributor.png" style="width:120px;height:120px;"/><h3 style="margin-top:-20px;">Login Pelanggan</h3></div></a>
    <a href="admin/masuk.php"><div id="logo"><img src="assets/img/user.png" width="90" style="width:65px;height:80px;margin-top:20px;"/><h3 style="margin-top:0px;">Login Admin</h3></div></a>
</div>
</body>
</html>
·         Berikut hasil index awalnya:
·         Dan berikut adalah halaman index  untuk folder upk_erawati/admin/..nah didalam folder ini kita akan membuat index, dan keluar.
·         Berikan css agar terlihat menarik. Kita namakan admin.css untuk cssnya kita simpan pada C:/xampp/htdocs/upk_erawati/assets/template/.
·         admin.css

.wrapper{
            width: 100%;
            height: 100%;
}
.navbar{
            margin-bottom: 0;
}
.sidebar{
            width: 100%;
            height: 100%;
            background: #0000FF;
            position: absolute;
            z-index: 100;
}
ul{
            padding: 0;
            margin-left: -40px;
}
ul li{
            list-style: none;
            border-bottom: 1px solid rgba(255, 255, 255, 0.5);
}
ul li a{
            text-decoration: none;
            color: #aeb2b7;
            display: block;
            padding: 19px 0px 18px 25px;
            transition: all 200ms ease-in;
}
ul li a:hover{
            text-decoration: none;
            color: #1abc9c;
}
ul li a:visited{
            text-decoration: none;
            color: #fff;
}
li li a span{
            display: inline-block;
}
ul ul{
            display: none;
            margin:0px;
}
ul li a .fa-angle-down{
            margin-right: 10px;
}
/*apabila lebar min 768px*/
@media(min-width: 768px) {
            .sidebar{
                        width: 240px;
            }
            .content{
                        margin-left: 250px;
            }
            .inner{
                        padding: 15px;
            }
}

·         index.php
<?php
session_start();
if(!empty($_SESSION['username_admin']) AND !empty($_SESSION['password_admin'])){
?>
<!DOCTYPE html>
<html>
<head>
            <link rel="stylesheet" href="../assets/template/style.css">
            <link rel="stylesheet" href="../assets/template/admin.css">
</head>
<body>
<div class="wrapper">
      <nav class="navbar navbar-default">
        <div><a class="navbar-brand" href="../index.php">Listrik</a></div>
      </nav>
      <aside class="sidebar">
        <menu>
          <ul class="menu-content">
            <li><a href="index.php?modal=beranda">Beranda</a></li>
                                    <li><a href="index.php?modal=pelanggan">Pelanggan</a></li>
                                    <li><a href="index.php?modal=tagihan">Tagihan</a></li>
            <li><a href="index.php?modal=tarif">Tarif</a></li>
                                    <li><a href="index.php?modal=pembayaran">Pembayaran</a></li>
                                    <li><a href="index.php?modal=keluar">Keluar</a></li>
          </ul>
        </menu>
      </aside>
</div>
<?php
if(isset($_GET['modal'])){
            $modal = $_GET['modal'];
            if($modal == "beranda"){
                        include "home.php";
            }elseif($modal == "pembayaran"){
                        if(isset($_GET['aksi'])){
                                    $aksi = $_GET['aksi'];
                                    if($aksi == "tambah"){
                                                include "pembayaran/tambah-pembayaran.php";
                                    }elseif($aksi == "edit"){
                                                include "pembayaran/edit-pembayaran.php";
                                    }elseif($aksi == "hapus"){
                                                include "pembayaran/hapus-pembayaran.php";
                                    }elseif($aksi == "detail"){
                                                include "pembayaran/detail-pembayaran.php";
                                    }else{
                                                include "pembayaran/home.php";
                                    }
                        }else{
                                    include "pembayaran/home.php";
                        }
            }elseif($modal == "tagihan"){
                        if(isset($_GET['aksi'])){
                                    $aksi = $_GET['aksi'];
                                    if($aksi == "tambah"){
                                                include "tagihan/tambah-tagihan.php";
                                    }elseif($aksi == "edit"){
                                                include "tagihan/edit-tagihan.php";
                                    }elseif($aksi == "hapus"){
                                                include "tagihan/hapus-tagihan.php";
                                    }elseif($aksi == "detail"){
                                                include "tagihan/detail-tagihan.php";
                                    }else{
                                                include "tagihan/home.php";
                                    }
                        }else{
                                    include "tagihan/home.php";
                        }
            }elseif($modal == "pelanggan"){
                        if(isset($_GET['aksi'])){
                                    $aksi = $_GET['aksi'];
                                    if($aksi == "tambah"){
                                                include "pelanggan/tambah-pelanggan.php";
                                    }elseif($aksi == "edit"){
                                                include "pelanggan/edit-pelanggan.php";
                                    }elseif($aksi == "hapus"){
                                                include "pelanggan/hapus-pelanggan.php";
                                    }elseif($aksi == "detail"){
                                                include "pelanggan/detail-pelanggan.php";
                                    }else{
                                                include "pelanggan/home.php";
                                    }
                        }else{
                                    include "pelanggan/home.php";
                        }
            }elseif($modal == "tarif"){
                                    include "tarif/home.php";
            }elseif($modal == "keluar"){
                        include "keluar.php";
            }else{
                        include "home.php";
            }
}else{
            include "home.php";
}
?>
</body>
</html>
<?php
}else{
            echo "<script>alert('Anda Harus Masuk Dahulu !!'); window.location='masuk.php'</script>";
}
·         home.php :
<title>Selamat Datang Admin</title>
<section class="ocntent">
<div class="inner">
            <h2 style="font-size:46px;position:relative;margin-left:250px;margin-top:-0px;color:#0000ff;text-decoration:none;line-height:   60px;font-family:Calibri;">Selamat Datang Admin </h2>
            <img src="../assets/img/era.jpg" style="margin-left: 250px; width: 220px; height: 150px;">
            <table style="margin-left:250px;" border="1">
            <tr>
                        <td>NAMA</td>
<td>ERAWATI SETYA NINGRUM</td>
</tr>
<tr>
<td>ALAMAT</td>  
<td>SOKAWATI</td>
</tr>
<tr>
<td>JABATAN</td>
<td>KASIR</td>
</tr>
                        <tr>
                        <td>NO TELP</td> 
                        <td>085217743594</td>
                        </tr>
            </table>         
</div>
</section>
·         keluar.php
<?php
error_reporting(0);
session_start();
session_destroy();
echo"<script>alert('Anda Berhasil Keluar'); document.location='masuk.php'</script>";
Maka hasilnya akan seperti ini :
7.      Selanjutnya kita buat Data Pelanggan seperti detail-pelanggan, edit-pelanggan, hapus-pelanggan, home, tambah-pelanggan. Untuk data pelanggan kita simpan pada C:/xampp/htdocs/upk_erawati/admin/pelanggan/..seperti berikut:
 
·         home.php

<title>Pelanggan</title>
<section class="content">
<div class="inner">
<br />
<center><a class="button biru" href="index.php?modal=pelanggan&aksi=tambah">Tambah Pelanggan</a>
<a class="button hijau" href="../admin/phpfpdf/report_pelanggan.php" target="_blank">REPORT</a>
</center>
<br />
<table class="tabel" align="center" width="80%">
            <tr>
                        <th>ID Pelanggan</th>
                        <th>Nama Pelanggan</th>
                        <th>Alamat</th>
                        <th>Aksi</th>
            </tr>
<?php
 include "../data/config.php";
 foreach(lihat_pelanggan() as $pelanggan):
?>
            <tr>
                        <td><?php echo $pelanggan['id_pelanggan']; ?></td>
                        <td><?php echo $pelanggan['nama_pelanggan']; ?></td>
                        <td><?php echo $pelanggan['alamat']; ?></td>
                        <td><a class="button hijau" href="index.php?modal=pelanggan&aksi=edit&id=<?php echo $pelanggan['id_pelanggan']; ?>">Edit</a> <a class="button merah" href="index.php?modal=pelanggan&aksi=hapus&id=<?php echo $pelanggan['id_pelanggan']; ?>" onclick="return confirm('Anda Yakin..?');">Hapus</a>  <a class="button biru" href="index.php?modal=pelanggan&aksi=detail&id=<?php echo $pelanggan['id_pelanggan']; ?>">Detail</a>  <a href="cetak-pelanggan.php?id=<?php echo $pelanggan['id_pelanggan']; ?>" target="_blank" class="button hijau">Cetak</a></td>
            </tr>
<?php endforeach; ?>
</table>
<br />
</div>
</section>


·         detail-pelanggan.php

<title>Detail Pelanggan</title>
<section class="content">
<div class="inner">
<br />
<center><img src="../assets/img/ak.jpg" class="img" width="200" height="200"></center>
<br />
<?php
include "../data/config.php";
if(isset($_GET['id'])):
            foreach(pilih_pelanggan($_GET['id']) as $pelanggan):
?>
                        <table align="center" class="tabel" width="70%">
                                    <tr>
                                                <td>ID Pelanggan</td>
                                                <td><?php echo $pelanggan['id_pelanggan']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Username</td>
                                                <td><?php echo $pelanggan['username']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Password</td>
                                                <td><?php echo base64_decode($pelanggan['password']); ?></td>
                                    </tr>
                                    <tr>
                                                <td>Nama Pelanggan</td>
                                                <td><?php echo $pelanggan['nama_pelanggan']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Alamat</td>
                                                <td><?php echo $pelanggan['alamat']; ?></td>
                                    </tr>
                                    <?php foreach(pilih_tarif($pelanggan['id_tarif']) as $tarif): ?>
                                    <tr>
                                                <td>Daya</td>
                                                <td><?php echo $tarif['daya']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Tarif Perkwh</td>
                                                <td><?php echo rupiah($tarif['tarifperkwh']); ?></td>
                                    </tr>
                                    <?php endforeach; ?>
                        </table>
                        <br />
                        <center>
                                    <a href="index.php?modal=pelanggan" class="button merah">Kembali</a> <a href="cetak-pelanggan.php?id=<?php echo $pelanggan['id_pelanggan']; ?>" target="_blank" class="button biru">Cetak</a>
                        </center>
            </form>
<?php endforeach; ?>
<?php endif; ?>
</div>
</section>
<br />
<br />
<br />


·         tambah-pelanggan.php

<title>Tambah Pelanggan</title>
<section class="content">
<div class="inner">
<?php include "../data/config.php"; ?>
<h3 align="center">Tambah Data Pelanggan</h3>
            <form action="" method="post">
                        <table align="center">
                                    <tr>
                                                <td>ID Pelanggan</td>
                                                <td><input class="input" disabled value="<?php echo id_pelanggan(); ?>"></td>
                                    </tr>
                                    <tr>
                                                <td>Username</td>
                                                <td><input class="input" type="teks" name="username" placeholder="Nama Pengguna"></td>
                                    </tr>
                                    <tr>
                                                <td>Password</td>
                                                <td><input class="input" type="password" name="password" placeholder="Katasandi"></td>
                                    </tr>
                                    <tr>
                                                <td>Nama Pelanggan</td>
                                                <td><input class="input" type="text" name="nama_pelanggan" placeholder="Nama Pelanggan"></td>
                                    </tr>
                                    <tr>
                                                <td>Alamat</td>
                                                <td><textarea name="alamat" class="input" placeholder="Alamat Lengkap"></textarea></td>
                                    </tr>
                                    <tr>
                                                <td>Daya</td>
                                                <td><select class="input" name="id_tarif">
                                                            <?php
                                                                        foreach(lihat_tarif() as $tarif):
                                                            ?>
                                                            <option value="<?php echo $tarif['id_tarif']; ?>"><?php echo $tarif['daya']; ?></option>
                                                            <?php endforeach; ?>
                                                </select></td>
                                    </tr>
                        </table>
                        <br />
                        <center>
                                    <a href="index.php?modal=pelanggan" class="button hijau">Kembali</a>  <input type="submit" name="simpan" value="Simpan" class="button biru">
                        </center>
            </form>
</div>
</section>
<?php
if(isset($_POST['simpan'])){
$id_pelanggan = id_pelanggan();
$username = $_POST['username'];
$password = base64_encode($_POST['password']);
$nama_pelanggan = $_POST['nama_pelanggan'];
$alamat = $_POST['alamat'];
$id_tarif = $_POST['id_tarif'];
$insert = tambah_pelanggan($id_pelanggan, $username, $password, $nama_pelanggan, $alamat, $id_tarif);
if($insert){
            echo "<script>alert('Data Berhasil Disimpan'); document.location='index.php?modal=pelanggan'</script>";
}else{
            echo "Data Gagal Disimpan";
}
}

·         edit-pelanggan.php

<title>Edit Data Pelanggan</title>
<section class="content">
<div class="inner">
<br />
<?php
include "../data/config.php";
if(isset($_GET['id'])):
            foreach(pilih_pelanggan($_GET['id']) as $pelanggan):
?>
            <form action="" method="post">
                        <table align="center" class="tabel" width="60%">
                                    <input type="hidden" name="id_pelanggan" value="<?php echo $pelanggan['id_pelanggan']; ?>">
                                    <tr>
                                                <td>ID Pelanggan</td>
                                                <td><input class="input" disabled value="<?php echo $pelanggan['id_pelanggan']; ?>"></td>
                                    </tr>
                                    <tr>
                                                <td>Username</td>
                                                <td><input class="input" type="text" name="username" value="<?php echo $pelanggan['username']; ?>"></td>
                                    </tr>
                                    <tr>
                                                <td>Password</td>
                                                <td><input class="input" type="text" name="password" value="<?php echo base64_decode($pelanggan['password']); ?>"></td>
                                    </tr>
                                    <tr>
                                                <td>Nama Pelanggan</td>
                                                <td><input class="input" type="text" name="nama_pelanggan" value="<?php echo $pelanggan['nama_pelanggan']; ?>"></td>
                                    </tr>
                                    <tr>
                                                <td>Alamat</td>
                                                <td><input class="input" type="text" name="alamat" value="<?php echo $pelanggan['alamat']; ?>"></td>
                                    </tr>
                                    <tr>
                                                <td>Daya</td>
                                                <td><select class="input" name="id_tarif">
                                                            <?php foreach(lihat_tarif() as $tarif): ?>
                                                            <option value="<?php echo $tarif['id_tarif']; ?>"><?php echo $tarif['daya']; ?></option>
                                                            <?php endforeach; ?>
                                                </select></td>
                                    </tr>
                        </table>
                        <br />
                        <center>
                                    <a href="index.php?modal=pelanggan" class="button hijau">Kembali</a>  <input class="button biru" type="submit" name="simpan" value="Simpan">
                        </center>
            </form>
<?php endforeach; ?>
<?php endif; ?>
</div>
</section>
<?php

if(isset($_POST['simpan'])){

$id_pelanggan = $_POST['id_pelanggan'];
$username = $_POST['username'];
$password = base64_encode($_POST['password']);
$nama_pelanggan = $_POST['nama_pelanggan'];
$alamat = $_POST['alamat'];
$id_tarif = $_POST['id_tarif'];

$insert = update_pelanggan($id_pelanggan, $username, $password, $nama_pelanggan, $alamat, $id_tarif);

if($insert){
            echo "<script>alert('Data Berhasil Diperbarui'); document.location='index.php?modal=pelanggan'</script>";
}else{
            echo "Data Gagal Diperbarui";
}
}

·         hapus-pelanggan.php

<?php
include "../data/config.php";
if(isset($_GET['id'])){
            $id = $_GET['id'];
            hapus_pelanggan($id);
            echo"<script>document.location='index.php?modal=pelanggan'</script>";
}
?>

·         Beginilah hasilnya:

8.      Selanjutnya kita buat Data Pembayaran seperti detail-pembayaran, edit-pembayaran, hapus-pembayaran, home, tambah-pembayaran. Untuk data pembayaran kita simpan pada C:/xampp/htdocs/upk_erawati/admin/pembayaran/..seperti berikut:
·         detail-pembayaran.php

<title>pembayaran</title>
<section class="content">
<div class="inner">
<br />
<?php
include "../data/config.php";
if(isset($_GET['id'])):
            foreach(pilih_pembayaran($_GET['id']) as $pembayaran):
?>
<br />
<h3 align="center">Detail Pembayaran <?php echo $pembayaran['id_pembayaran']; ?></h3>
<br />
                        <table align="center">
                                    <tr>
                                                <td>ID Pembayaran</td>
                                                <td><?php echo $pembayaran['id_pembayaran']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>ID Tagihan</td>
                                                <td><?php echo $pembayaran['id_tagihan']; ?></td>
                                    </tr>  
                                    <?php foreach(pilih_pelanggan($pembayaran['id_pelanggan']) as $pelanggan): ?>
                                                <td>Nama Pelanggan</td>
                                    <td><?php echo $pelanggan['nama_pelanggan']; ?></td>
                                    <?php endforeach; ?>
                                    <tr>
                                                <td>Penagihan</td>
                                                <td><?php echo $pembayaran['bulan']." ".$pembayaran['tahun']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Metode Pembayaran</td>
                                                <td><?php echo $pembayaran['metode']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Bukti Transfer</td>
                                                <td><img src="../assets/img/bukti_transfer/<?php echo $pembayaran['bukti']; ?>" width="300" height="200"></td>
                                    </tr>
                                    <tr>
                                                <td>Status</td>
                                                <td><?php echo $pembayaran['status']; ?></td>
                                    </tr>
                        </table>
                        <br />
                        <center>
                                    <a class="button merah" href="index.php?modal=pembayaran">Kembali</a>
                        </center>
<?php endforeach; ?>
<?php endif; ?>
<br />
</body>
</html>

·         edit-pembayaran.php

<title>pembayaran</title>
<section class="content">
<div class="inner">
<br />
<?php
include "../data/config.php";
if(isset($_GET['id'])):
            foreach(pilih_pembayaran($_GET['id']) as $pembayaran):
?>
<br />
<h3 align="center">Edit Pembayaran <?php echo $pembayaran['id_pembayaran']; ?></h3>
<br />
                        <table align="center">
                                    <tr>
                                                <td>ID Pembayaran</td>
                                                <td><?php echo $pembayaran['id_pembayaran']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>ID Tagihan</td>
                                                <td><?php echo $pembayaran['id_tagihan']; ?></td>
                                    </tr>  
                                    <?php foreach(pilih_pelanggan($pembayaran['id_pelanggan']) as $pelanggan): ?>
                                                <td>Nama Pelanggan</td>
                                    <td><?php echo $pelanggan['nama_pelanggan']; ?></td>
                                    <?php endforeach; ?>
                                    <tr>
                                                <td>Penagihan</td>
                                                <td><?php echo $pembayaran['bulan']." ".$pembayaran['tahun']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Metode Pembayaran</td>
                                                <td><?php echo $pembayaran['metode']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Bukti Transfer</td>
                                                <td><img src="../assets/img/bukti_transfer/<?php echo $pembayaran['bukti']; ?>" width="300" height="200"></td>
                                    </tr>
                                    <form action="" method="post">                            
                                    <tr>
                                                <input type="hidden" name="id_pembayaran" value="<?php echo $pembayaran['id_pembayaran']; ?>">
                                                <td>Status</td>
                                                <td><select name="status" class="input">
                                                            <option <?php if($pembayaran['status'] == "Pending"){ echo "selected"; } ?> value="Pending">Pending</option>
                                                            <option <?php if($pembayaran['status'] == "Terima"){ echo "selected"; } ?> value="Terima">Terima</option>
                                                </select></td>
                                    </tr>
                        </table>
                        <br />
                        <center>
                                    <a class="button merah" href="index.php?modal=pembayaran">Kembali</a>&nbsp;<input type="submit" name="simpan" value="Simpan" class="button biru">
                        </center>
<?php endforeach; ?>
<?php endif; ?>
</form>
<br />
</body>
</html>
<?php
if(isset($_POST['simpan'])){
            $id_pembayaran = $_POST['id_pembayaran'];
            $status        = $_POST['status'];
            $update = update_pembayaran($id_pembayaran, $status);
            if($update){
                        echo "<script>alert('Data Berhasil Disimpan'); document.location='index.php?modal=pembayaran'</script>";
            }else{
                        echo "Data Gagal Disimpan";
            }
}

·         hapus-pembayaran.php

<?php
include "../data/config.php";

if (isset($_GET['id'])) {
            $id=$_GET['id'];
            hapus_pembayaran($id);
            echo"<script>document.location='index.php?modal=pembayaran'</script>";
}

?>

·         home.php

<title>Pembayaran</title>
<section class="content">
<div class="inner">
<br />
<table align="center" class="tabel">
            <tr>
                        <td colspan="7">
                                    <center>
            <a class="button merah" href="../admin/phpfpdf/report_pembayaran.php">REPORT</a>
<a class="button hijau" href="../masuk.php">Tambah Bayar</a>
</center>
                        </td>
            </tr>
<tr>
            <td>ID Pembayaran</td>
            <td>Nama Pelanggan</td>
            <td>Penagihan</td>
            <td>Tanggal Bayar</td>
            <td>Biaya</td>
            <td>Status</td>
            <td align="center">Aksi</td>
</tr>  
<?php
include "../data/config.php";
foreach(lihat_pembayaran() as $pembayaran):
?>
<tr>
            <td><?php echo $pembayaran['id_pembayaran']; ?></td>
            <?php foreach(pilih_pelanggan($pembayaran['id_pelanggan']) as $pelanggan): ?>
            <td><?php echo $pelanggan['nama_pelanggan']; ?></td>
            <?php endforeach; ?>
            <td><?php echo $pembayaran['bulan']." ".$pembayaran['tahun']; ?></td>
            <td><?php echo $pembayaran['tgl_bayar']; ?></td>
            <td><?php echo rupiah($pembayaran['biaya']); ?></td>
            <td><?php echo $pembayaran['status']; ?></td>
<td><a class="button merah" href="index.php?modal=pembayaran&aksi=hapus&id=<?php echo $pembayaran['id_pembayaran']; ?>" onclick="return confirm('anda yakin akan menghapusnya?');">Hapus</a>&nbsp;<a class="button hijau" href="index.php?modal=pembayaran&aksi=edit&id=<?php echo $pembayaran['id_pembayaran']; ?>">Edit</a>&nbsp;<a class="button biru" href="index.php?modal=pembayaran&aksi=detail&id=<?php echo $pembayaran['id_pembayaran']; ?>">Detail</a> <a href="cetak-pembayaran.php?id=<?php echo $pembayaran['id_pembayaran']; ?>" target="_blank" class="button hijau">Cetak</a>
</td>
<?php
$total = $total;
$total = $total+$pembayaran['biaya'];
?>
</tr>
<?php endforeach; ?>
<tr>
            <td colspan="6">Total</td>
            <td><?php echo rupiah($total); ?></td>
</tr>
</table>
</form>
<br />
</div>
</section>

·         tambah-pembayaran.php

<title>Tambah Pembayaran</title>
<section class="content">
<div class="inner">
<br />
            <form action="" method="post">
                        <table align="center">
                                    <tr>
                                                <td>id pembayaran</td>
                                                <td><input type="text" name="id_pembayaran"></td>
                                    </tr>
                                    <tr>
                                                <td>id tagihan</td>
                                                <td><input type="text" name="id_tagihan"></td>
                                    </tr>
                                    <tr>
                                                <td>id pelanggan</td>
                                                <td><input type="text" name="id_pelanggan"></td>
                                    </tr>
                                    <tr>
                                                <td>tgl pembayaran</td>
                                                <td><input type="text" name="tgl_pembayaran"></td>
                                    </tr>
                                    <tr>
                                                <td>bulan bayar</td>
                                                <td><input type="text" name="bulan_bayar"></td>
                                    </tr>
                                    <tr>
                                                <td>biaya admin</td>
                                                <td><input type="text" name="biaya_admin"></td>
                                    </tr>
                                    <tr>
                                                <td>total bayar</td>
                                                <td><input type="text" name="total_bayar"></td>
                                    </tr>
                        </table>
                        <br />
                        <center>
                                    <a class="button merah" href="index.php?modal=pembayaran">Kembali</a>  <input class="button hijau" type="submit" name="simpan" value="Simpan">
                        </center>
            </form>
<?php
if(isset($_POST['simpan'])){
            $id_pembayaran  = $_POST['id_pembayaran'];
            $id_tagihan     = $_POST['id_tagihan'];
            $id_pelanggan   = $_POST['id_pelanggan'];
            $tgl_pembayaran = $_POST['tgl_pembayaran'];
            $bulan_bayar    = $_POST['bulan_bayar'];
            $biaya_admin    = $_POST['biaya_admin'];
            $total_bayar    = $_POST['total_bayar'];

$insert = tambah_pembayaran($id_pembayaran, $id_tagihan, $id_pelanggan, $tgl_pembayaran, $bulan_bayar, $biaya_admin, $total_bayar);
if($insert){
            echo "Berhasil";
}else{
            echo "Gagal";
}
}

·         Beginilah hasilnya:

9.      Selanjutnya kita buat Data Pembayaran seperti hapus-tagihan, home, tambah-tagihan. Untuk data tagihan kita simpan pada C:/xampp/htdocs/upk_erawati/admin/tagihan/..seperti berikut:

·         Hapus-tagihan.php

<?php
include "../data/config.php";
if(isset($_GET['id'])){
            $id = $_GET['id'];
            hapus_tagihan($id);
            echo"<script>document.location='index.php?modal=tagihan'</script>";
}

?>

·         Home.php

<title>Tagihan</title>
<section class="content">
<div class="inner">
<br />
<center><a class="button biru" href="index.php?modal=tagihan&aksi=tambah">Tambah Tagihan</a></center>
<br />
<table class="tabel" align="center">
            <tr>
                        <th>ID Tagihan</th>
                        <th>ID Pelanggan</th>
                        <th>bulan</th>
                        <th>tahun</th>
                        <th>Penggunaan Watt</th>
                        <th>Status</th>
                        <th>Aksi</th>
            </tr>
<?php
 include "../data/config.php";
 foreach(lihat_tagihan() as $tagihan):
?>
            <tr>
                        <td><?php echo $tagihan['id_tagihan']; ?></td>
                        <td><?php echo $tagihan['id_pelanggan']; ?></td>
                        <td><?php echo $tagihan['bulan']; ?></td>
                        <td><?php echo $tagihan['tahun']; ?></td>
                        <td><?php echo $tagihan['jumlah_meter']; ?></td>
                        <td><?php echo $tagihan['status']; ?></td>
                        <td><a class="button merah" href="index.php?modal=tagihan&aksi=hapus&id=<?php echo $tagihan['id_tagihan']; ?>" onclick="return confirm('Anda Yakin..?');">Hapus</a>
<a class="button hijau" target="_blank" href="cetak-tagihan.php">Cetak</a>
                        </td>
            </tr>
<?php endforeach; ?>
</table>
<br />
<center><a class="button biru" href="../admin/phpfpdf/report_tagihan.php">REPORT</a></center>
<br />
</div>
</section>

·         Tambah-tagihan

<title>Tambah Tagihan</title>
<section class="content">
<div class="inner">
<br />
<?php include "../data/config.php"; ?>
            <form action="" method="post">
                        <table align="center">
                                    <tr>
                                                <td>ID Tagihan</td>
                                                <td><input class="input" disabled value="<?php echo id_tagihan(); ?>"></td>
                                    </tr>
                                    <tr>
                                                <td>Pelanggan</td>
                                                <td><select name="id_pelanggan" class="input">
                                    <?php foreach(lihat_pelanggan() as $pelanggan): ?>
                                                            <option value="<?php echo $pelanggan['id_pelanggan']; ?>"><?php echo $pelanggan['nama_pelanggan']; ?></option>
                                    <?php endforeach; ?>
                                                </select></td>
                                    </tr>
                                    <tr>
                                                <td>Bulan</td>
                                                <td><select name="bulan" class="input">
                                                            <option value="Januari">Januari</option>
                                                            <option value="Febuari">Febuari</option>
                                                            <option value="Maret">Maret</option>
                                                            <option value="April">April</option>
                                                            <option value="Mei">Mei</option>
                                                            <option value="Juni">Juni</option>
                                                            <option value="Juli">Juli</option>
                                                            <option value="Agustus">Agustus</option>
                                                            <option value="September">September</option>
                                                            <option value="Oktober">Oktober</option>
                                                            <option value="November">November</option>
                                                            <option value="Desember">Desember</option>
                                                </select></td>
                                    </tr>
                                    <tr>
                                                <td>Tahun</td>
                                                <td><input class="input" type="text" name="tahun" placeholder="Masukan Tahun"></td>
                                    </tr>
                                    <tr>
                                                <td>Jumlah Meter</td>
                                                <td><input class="input" type="text" name="jumlah_meter" placeholder="Jumlah Penggunaan"></td>
                                    </tr>
                                    <input type="hidden" name="id_tarif" value="<?php echo $pelanggan['id_tarif']; ?>">
                        </table>
                        <br />
                        <center>
                                    <a class="button merah" href="index.php?modal=tagihan">Kembali</a>  <input class="button biru" type="submit" name="simpan" value="Simpan">
                        </center>
            </form>
</div>
</section>
<?php
if(isset($_POST['simpan'])){
foreach(pilih_tarif($_POST['id_tarif']) as $tarif):
$id_tagihan = id_tagihan();
$id_pelanggan = $_POST['id_pelanggan'];
$bulan = $_POST['bulan'];
$tahun = $_POST['tahun'];
$jumlah_meter = $_POST['jumlah_meter'];
$biaya = $jumlah_meter*$tarif['tarifperkwh'];
$insert = tambah_tagihan($id_tagihan, $id_pelanggan, $bulan, $tahun, $jumlah_meter, $biaya, "Belum Bayar");
if($insert){
            echo "<script>alert('Data Berhasil Disimpan'); document.location='index.php?modal=tagihan'</script>";
}else{
            echo "Data Gagal Disimpan";
}
endforeach;
}

·         Beginilah hasilnya:

10.  Selanjutnya kita buat Data Tarif home tarif. Untuk data tarif kita simpan pada C:/xampp/htdocs/upk_erawati/admin/tarif/..seperti berikut
·         Home.php

<title>Lihat Tarif</title>
<section class="content">
<div class="inner">
<br />
<br />
<table border="1" align="center" class="tabel">
            <tr>
                        <td colspan="3">
                        <center>
            <a class="button biru" href="../admin/phpfpdf/report_tarif.php">CETAK</a>
</center>       
                        </td>
            </tr>
            <tr>
                        <th>ID tarif</th>
                        <th>Daya</th>
                        <th>Tarif Perkwh</th>
            </tr>
<?php
 include "../data/config.php";
 foreach(lihat_tarif() as $tarif):
?>
            <tr>
                        <td><?php echo $tarif['id_tarif']; ?></td>
                        <td><?php echo $tarif['daya']; ?></td>
                        <td><?php echo $tarif['tarifperkwh']; ?></td>
            </tr>
<?php endforeach; ?>

·         Beginilah hasilnya:
11.  Selanjutnya kita buat tampilan untuk pelanggan. Pertama yaitu header, profil, pembayaran, tagihan dan keluar. kita simpan pada C:/xampp/htdocs/upk_erawati/.. seperti berikut:

·         Header.php

           
            <!-- bagian header template -->
            <header>
                        <link rel="stylesheet" type="text/css" href="assets/template/beranda.css"></head>
                        <h1 class="judul">Aplikasi Pembayaran Listrik</h1>
                        <p class="deskripsi">Pembayaran Listrik Pasca Bayar Melalui Payment Point Online Bank</p>
            </header>
            <!-- akhir bagian header template -->
           
            <div class="wrap">
                        <!-- bagian menu -->
                        <nav class="menu">
                                    <ul>
<?php
session_start();
if(!empty($_SESSION['id_pelanggan']) AND !empty($_SESSION['user']) AND !empty($_SESSION['pass'])):
?>
                                                <li><a href="index.php">Beranda</a></li>
                                                <li><a href="tagihan.php">Tagihan</a></li>
                                                <li><a href="pembayaran.php">Pembayaran</a></li>
                                                <li><a href="profil.php">Profil</a></li>
                                                <li><a href="keluar.php">Keluar</a></li>
<?php else: ?>
                                                <li><a href="index.php">Beranda</a></li>
                                                <li><a href="masuk.php">Masuk</a></li>
<?php endif; ?>
                                    </ul>
                        </nav>
                        <!-- akhir bagian menu -->

                        <!-- bagian sidebar website -->
                        <aside class="sidebar">
                                    <div class="widget">
                                                <h2 align="center">RPL</h2>
                                                <p>Mempelajari dan mendalami semua cara-cara pengembangan perangkat lunak termasuk berkaitan dengan software computer mulai dari pembuatan website, aplikasi, game dan semua yang berkaitan dengan pemrograman dengan menguasai bahasa pemrograman tersebut</p>
                                    </div>
                                    <div class="widget">
                                                <h2 align="center">SATYA PRAJA 2</h2>
                                                <p>Merupakan salah satu sekolah menengah keatas swasta yang berada di daerah petarukan.</p>
                                    </div>
                        </aside>
                        <!-- akhir bagian sidebar website -->

·         Jangan lupa berikan css agar terlihat bagus. Kita namakan beranda.css kita tematkan pada C:/xampp/htdocs/upk_erawati/assets/template/..seperti berikut:
·         Beranda.css

body {
    background: #eee;
    margin:0;
    font-family: sans-serif;
}
header{
    text-align: center;
    color: #232323;
}
.wrap {
    width: 1100px;
    margin:15px auto;
}
nav.menu ul {
    color:#fff;
    list-style: none;
    float:left;
    padding:0;
    width: 800px;
    margin:0 0 0;
    background: #60c;
}
nav.menu ul li {
    margin:0;
    float:left;
}
nav.menu ul a {
    padding:25px;
    display:block;
    font-weight:600;
    color:#fff;
    text-decoration: none;
}
nav.menu ul a:hover {
    background:#0cc;
}
.sidebar {
    float:right;
    width:275px;
}
.sidebar .widget {
    padding:25px;
    margin:0 0 25px;
    background:#fff;
    border-bottom: 2px solid #fff;
}
.sidebar .widget h2 {
    padding:0;
    margin:0 0 15px;
    color:#3498db;
}
.blog {
    float:left;
}
.conteudo {
    width:750px;
    padding:25px;
    margin:25px auto;
    background: #fff;
    border:1px solid #dedede;
}
.conteudo img {
    width: 100%;
    margin-bottom:25px;
}
.conteudo .img{
    width: 50%;
    height: 50%;
    border-radius: 48%;
    border: 2px solid #000;
}

·         Beginilah hasilnya:
·         Tagihan.php

<?php
error_reporting(0);
session_start();
if(!empty($_SESSION['id_pelanggan']) AND !empty($_SESSION['user']) AND !empty($_SESSION['pass'])):
?>
<!DOCTYPE html>
<html>
<head>
            <title>Bayar Tagihan Listrik</title>
            <link rel="stylesheet" href="assets/template/style.css">
            <link rel="stylesheet" href="assets/template/beranda.css">
</head>
<body>
<?php include "header.php"; ?>
                        <!-- bagian konten Blog -->
                        <div class="blog">
<?php include "data/config.php"; ?>
<?php if(isset($_GET['id'])): ?>
<?php foreach(pilih_tagihan($_GET['id']) as $tagihan): ?>
<div class="conteudo">

            <form action="" method="post" enctype="multipart/form-data">
                        <table align="center">
                                    <tr>
                                                <td>ID Pembayaran</td>
                                                <td><input class="input" disabled value="<?php echo id_pembayaran(); ?>"></td>
                                    </tr>
                                                <input type="hidden" name="id_tagihan" value="<?php echo $tagihan['id_tagihan']; ?>">
                                                <input type="hidden" name="id_pelanggan" value="<?php echo $tagihan['id_pelanggan']; ?>">
                                                <input type="hidden" name="bulan" value="<?php echo $tagihan['bulan']; ?>">
                                                <input type="hidden" name="tahun" value="<?php echo $tagihan['tahun']; ?>">
                                    <tr>
                                                <td>Tanggal Bayar</td>
                                                <td><input class="input" type="date" name="tgl_bayar"></td>
                                    </tr>
                                    <tr>
                                                <td>Metode Pembayaran</td>
                                                <td><select class="input" name="metode">
                                                            <option value="Token Listrik">Token Listrik</option>
                                                            <option value="Pulsa">Pulsa</option>
                                                            <option value="Transfer Bank">Transfer Bank</option>
                                                            <option value="Cash">Cash </option>
                                                </select></td>
                                    </tr>
                                    <tr>
                                                <td>Bukti Transaksi</td>
                                                <td><input type="file" name="bukti"></td>
                                    </tr>
                                    <tr>
                                                <td>Biaya</td>
                                                <td><input type="hidden" name="biaya" value="<?php echo $tagihan['biaya']; ?>"><?php echo rupiah($tagihan['biaya']); ?></td>
                                    </tr>
                        </table>
                        <br />
                        <center>
                                    <a class="button merah" href="index.php?modal=pembayaran">Kembali</a>  <input class="button hijau" type="submit" name="simpan" value="Simpan">
                        </center>
            </form>

</div>
<?php endforeach; ?>
<?php else: ?>
<?php
foreach(pilih_pelanggan($_SESSION['id_pelanggan']) as $pelanggan):
?>
                                    <div class="conteudo">
                                                <center>
                                                            <img src="assets/img/ak.jpg" class="img">
                                                </center>
                                                <h1 align="center">Riwayat Tagihan untuk <?php echo $pelanggan['nama_pelanggan']; ?></h1>
                                                <hr>
                        <form action="" method="post">
<table class="tabel" align="center">
            <tr>
                        <th>ID Tagihan</th>
                        <th>Bulan</th>
                        <th>Tahun</th>
                        <th>Biaya</th>
                        <th>Status</th>
                        <th>Aksi</th>
            </tr>
<?php foreach(pelanggan_tagihan($pelanggan['id_pelanggan']) as $tagihan): ?>
<?php if($tagihan): ?>
            <tr>
                        <td><?php echo $tagihan['id_tagihan']; ?></td>
                        <td><?php echo $tagihan['bulan']; ?></td>
                        <td><?php echo $tagihan['tahun']; ?></td>
                        <td><?php echo rupiah($tagihan['biaya']); ?></td>
                        <td><?php echo $tagihan['status']; ?></td>
                        <td><?php if($tagihan['status'] == "Telah DiBayar"): ?>
                                    Selesai
                                    <?php else: ?>
                                    <a class="button biru" href="tagihan.php?id=<?php echo $tagihan['id_tagihan']; ?>">Bayar</a></td>
                                    <?php endif; ?>
            </tr>
<?php else: ?>
            <tr>
                        <td colspan="5">Data Tagihan Kosong</td>
            </tr>
<?php endif; ?>
<?php endforeach; ?>
</table>                     
                        </form>                                 
                                    </div>
                        </div>
<?php endforeach; ?>
<?php endif; ?>
                        <!-- akhir bagian konten Blog -->
            </div>
</body>
</html>
<?php else: ?>
<script>alert('Anda Haru Masuk Dahulu !!'); document.location='masuk.php'</script>
<?php endif; ?>

<?php

if(isset($_POST['simpan'])){
            $id_pembayaran  = id_pembayaran();
            $id_tagihan     = $_POST['id_tagihan'];
            $id_pelanggan   = $_POST['id_pelanggan'];
            $bulan = $_POST['bulan'];
            $tahun = $_POST['tahun'];
            $metode = $_POST['metode'];
            $tgl_bayar = $_POST['tgl_bayar'];
            $biaya    = $_POST['biaya'];
                                    $ekstensi_diperbolehkan         = array('png','jpg', 'jpeg');
                                    $nama = $_FILES['bukti']['name'];
                                    $x = explode('.', $nama);
                                    $ekstensi = strtolower(end($x));
                                    $ukuran           = $_FILES['bukti']['size'];
                                    $file_tmp = $_FILES['bukti']['tmp_name'];
                                    $nama_file = uniqid().".".$ekstensi;  

move_uploaded_file($file_tmp, 'assets/img/bukti_transfer/'.$nama_file);
$insert = tambah_pembayaran($id_pembayaran, $id_tagihan, $id_pelanggan, $bulan, $tahun, $metode, $nama_file, $tgl_bayar, $biaya, "Pending");
update_tagihan($id_tagihan);
if($insert){
            echo "<script>alert('Terima kasih'); document.location='pembayaran.php'</script>";
}else{
            echo "Data Gagal Disimpan";
}
}

·         Beginilah hasilnya:


·         Pembayaran.php

<?php
error_reporting(0);
session_start();
if(!empty($_SESSION['id_pelanggan']) AND !empty($_SESSION['user']) AND !empty($_SESSION['pass'])):
?>
<!DOCTYPE html>
<html>
<head>
            <title>Aplikasi Pembayaran Listrik Pasca Bayar</title>
            <link rel="stylesheet" href="assets/template/style.css">
            <link rel="stylesheet" href="assets/template/beranda.css">
</head>
<body>
<?php include "header.php"; ?>
                        <!-- bagian konten Blog -->
<div class="blog">
<?php include "data/config.php"; ?>
<?php if(isset($_GET['id'])): ?>
<?php foreach(pilih_pembayaran($_GET['id']) as $pembayaran): ?>
<div class="conteudo">
<center><img src="assets/img/ak.jpg" class="img"></center>
<h1 align="center">Detail Pembayaran <?php echo $pembayaran['id_pembayaran']; ?></h1>
<hr>
                        <table align="center">
                                    <tr>
                                                <td>ID Pembayaran</td>
                                                <td><?php echo $pembayaran['id_pembayaran']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>ID Tagihan</td>
                                                <td><?php echo $pembayaran['id_tagihan']; ?></td>
                                    </tr>  
                                    <?php foreach(pilih_pelanggan($pembayaran['id_pelanggan']) as $pelanggan): ?>
                                                <td>Nama Pelanggan</td>
                                    <td><?php echo $pelanggan['nama_pelanggan']; ?></td>
                                    <?php endforeach; ?>
                                    <tr>
                                                <td>Penagihan</td>
                                                <td><?php echo $pembayaran['bulan']." ".$pembayaran['tahun']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Metode Pembayaran</td>
                                                <td><?php echo $pembayaran['metode']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Bukti Transfer</td>
                                                <td><img src="assets/img/bukti_transfer/<?php echo $pembayaran['bukti']; ?>" width="300" height="200"></td>
                                    </tr>
                                    <tr>
                                                <td>Status</td>
                                                <td><?php echo $pembayaran['status']; ?></td>
                                    </tr>
                        </table>
                        <br />
                        <center>
                                    <a class="button merah" href="pembayaran.php">Kembali</a>
                        </center>
</div>
<?php endforeach; ?>
<?php else: ?>
<?php
foreach(pilih_pelanggan($_SESSION['id_pelanggan']) as $pelanggan):
?>
                                    <div class="conteudo">
                                                <center>
                                                            <img src="assets/img/ak.jpg" class="img">
                                                </center>
                                                <h1 align="center">Riwayat Pembayaran untuk <?php echo $pelanggan['nama_pelanggan']; ?></h1>
                                                <hr>
                        <form action="" method="post">
<table class="tabel" align="center">
            <tr>
                        <th>ID Pembayaran</th>
                        <th>Penagihan</th>
                        <th>Biaya</th>
                        <th>Status</th>
                        <th>Aksi</th>
            </tr>
<?php foreach(pelanggan_pembayaran($pelanggan['id_pelanggan']) as $pembayaran): ?>
<?php if($pembayaran): ?>
            <tr>
                        <td><?php echo $pembayaran['id_pembayaran']; ?></td>
                        <td><?php echo $pembayaran['bulan']." ".$pembayaran['tahun']; ?></td>
                        <td><?php echo rupiah($pembayaran['biaya']); ?></td>
                        <td><?php echo $pembayaran['status']; ?></td>
                        <td>
                                    <?php if($pembayaran['status'] == "Pending"): ?>
                                    <a href="pembayaran.php?id=<?php echo $pembayaran['id_pembayaran']; ?>" class="button merah">Detail</a>
                                    <?php else: ?>
                                    <a href="pembayaran.php?id=<?php echo $pembayaran['id_pembayaran']; ?>" class="button biru">Detail</a>
                                    <?php endif; ?>
                        </td>
            </tr>
<?php else: ?>
            <tr>
                        <td colspan="5">Data Pembayaran Kosong</td>
            </tr>
<?php endif; ?>
<?php endforeach; ?>
</table>                     
                        </form>                                 
                                    </div>
                        </div>
<?php endforeach; ?>
                        </div>
<?php endif; ?>
                        <!-- akhir bagian konten Blog -->
            </div>
</body>
</html>
<?php else: ?>
<script>alert('Anda Haru Login Dahulu !!'); document.location='login.php'</script>
<?php endif; ?>

·         Beginilah hasilnya:


·         Profil.php

<?php
error_reporting(0);
session_start();
if(!empty($_SESSION['id_pelanggan']) AND !empty($_SESSION['user']) AND !empty($_SESSION['pass'])):
?>
<!DOCTYPE html>
<html>
<head>
            <title>Profil Pengguna</title>
            <link rel="stylesheet" href="assets/template/style.css">
            <link rel="stylesheet" href="assets/template/beranda.css">
</head>
<body>
<?php include "header.php"; ?>
                        <!-- bagian konten Blog -->
                        <div class="blog">
<?php
include "data/config.php";
foreach(pilih_pelanggan($_SESSION['id_pelanggan']) as $pelanggan):
?>
                                    <div class="conteudo">
                                                <center>
                                                            <img src="assets/img/ak.jpg" class="img">
                                                </center>
                                                <h1 align="center">Profil <?php echo $pelanggan['nama_pelanggan']; ?></h1>
                                                <hr>
                                                            <form action="" method="post">
                        <table align="center" class="tabel" width="70%">
                                    <tr>
                                                <td>ID Pelanggan</td>
                                                <td><?php echo $pelanggan['id_pelanggan']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Username</td>
                                                <td><?php echo $pelanggan['username']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Password</td>
                                                <td><?php echo base64_decode($pelanggan['password']); ?></td>
                                    </tr>
                                    <tr>
                                                <td>Nama Pelanggan</td>
                                                <td><?php echo $pelanggan['nama_pelanggan']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Alamat</td>
                                                <td><?php echo $pelanggan['alamat']; ?></td>
                                    </tr>
                                    <?php foreach(pilih_tarif($pelanggan['id_tarif']) as $tarif): ?>
                                    <tr>
                                                <td>Daya</td>
                                                <td><?php echo $tarif['daya']; ?></td>
                                    </tr>
                                    <tr>
                                                <td>Tarif Perkwh</td>
                                                <td><?php echo rupiah($tarif['tarifperkwh']); ?></td>
                                    </tr>
                                    <?php endforeach; ?>
                        </table>                                             
                                    </div>
                        </div>
<?php endforeach; ?>
                        <!-- akhir bagian konten Blog -->
            </div>

</body>
</html>
<?php else: ?>
<script>alert('Anda Haru Masuk Dahulu !!'); document.location='masuk.php'</script>
<?php endif; ?>

·         Maka hasilnya seperti berikut:
·         Keluar.php


<?php
session_start();
session_destroy();
echo "<script>alert('Anda Berhasil Keluar'); document.location='index.php'</script>";
?>
4.      Report
Oke guys sekarang kita ada ditahap terakhir yaitu pembuatan laporan pembayaran.

<?php
//koneksi ke database
$host = "localhost";
$user = "root";
$pass = "";
$dbnm = "db_listrik";
$conn = mysql_connect($host, $user, $pass);
if ($conn) {
      $open = mysql_select_db($dbnm);
      if (!$open) {
                  die ("Database tidak dapat dibuka karena ".mysql_error());
      }
} else {
      die ("Server MySQL tidak terhubung karena ".mysql_error());
}
//akhir koneksi
#ambil data di tabel dan masukkan ke array
$query = "SELECT * FROM pembayaran";
$sql = mysql_query($query);
$data = array();
while ($row = mysql_fetch_assoc($sql)) {
      array_push($data, $row);
}    
#setting judul laporan dan header tabel
$judul = "LAPORAN DATA PEMBAYARAN";
$header = array(
                  array("label"=>"ID", "length"=>15, "align"=>"L"),
                  array("label"=>"ID Tag", "length"=>15, "align"=>"L"),
                  array("label"=>"ID Plg", "length"=>15, "align"=>"L"),
                  array("label"=>"Bulan", "length"=>20, "align"=>"L"),
                  array("label"=>"Tahun", "length"=>15, "align"=>"L"),
                  array("label"=>"Metode", "length"=>25, "align"=>"L"),
                  array("label"=>"Bukti", "length"=>35, "align"=>"L"),
                  array("label"=>"Tgl Bayar", "length"=>20, "align"=>"L"),
                  array("label"=>"Biaya", "length"=>15, "align"=>"L"),
                  array("label"=>"Status", "length"=>15, "align"=>"L"),
      );
#sertakan library FPDF dan bentuk objek
require_once ("phpfpdf/fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
#tampilkan judul laporan
$pdf->SetFont('Arial','B','16');
$pdf->Cell(0,20, $judul, '0', 1, 'C');
#buat header tabel
$pdf->SetFont('Arial','','10');
$pdf->SetFillColor(255,0,0);
$pdf->SetTextColor(255);
$pdf->SetDrawColor(128,0,0);
foreach ($header as $kolom) {
      $pdf->Cell($kolom['length'], 6, $kolom['label'], 1, '0', $kolom['align'], true);
}
$pdf->Ln();
#tampilkan data tabelnya
$pdf->SetFillColor(224,235,255);
$pdf->SetTextColor(0);
$pdf->SetFont('');
$fill=false;
foreach ($data as $baris) {
      $i = 0;
      foreach ($baris as $cell) {
                  $pdf->Cell($header[$i]['length'], 6, $cell, 1, '0', $kolom['align'], $fill);
                  $i++;
      }
      $fill = !$fill;
      $pdf->Ln();
}
#output file PDF
$pdf->Output();
?>

·         Maka inilah hasilnya:
 

Tidak ada komentar:

Posting Komentar