Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Update 20/12/2019
Browse files Browse the repository at this point in the history
 # fix issue validasi tambah dan edit di semua halaman CRUD
 # perbaikan pencarian jenis buku
 # memperbaiki transaki peminjaman
 # BUG laporan > pengembalian
  • Loading branch information
andrizan committed Dec 20, 2019
1 parent a27f737 commit 8347051
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 115 deletions.
31 changes: 23 additions & 8 deletions class/crud.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
<?php
class proses{
function __construct(){
date_default_timezone_set("Asia/Jakarta");
$server = "localhost";
$user = "root";
$pass = "";
$user = "admin";
$pass = "admin";
$db = "db_perpustakaan";
$this->con = new PDO("mysql:host=$server;dbname=$db",$user,$pass);
$this->con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
function simpan($tabel,$val){
$qw = "INSERT INTO $tabel VALUES ($val)";
Expand All @@ -22,10 +24,24 @@ function hapus($tabel,$property){
function tampil($select,$tabel,$property){
$qw = "SELECT $select FROM $tabel $property";
$tam = $this->con->query($qw);
return $tam;
return $tam;
}
function getKodePinjam()
{
$sql = "SELECT MAX(id_pinjam) as kode FROM detail_pinjam";
$ex = $this->con->query($sql);
$dt = $ex->fetch();
$kode = $dt['kode'];

$nu = (int) substr($kode, 3,4);
$nu++;

$char = "PNJ";
$newid = $char . sprintf("%04s",$nu);
return $newid;
}
}
class input{
class inputClass{
function input($type=null,$nama=null,$val=null,$property=null){
$input = "<input type='$type' name='$nama' value='$val' $property>";
return $input;
Expand Down Expand Up @@ -74,10 +90,9 @@ function form($sts=null,$action=null){
}
}
function base_url($folder){
$url = "http://localhost:81/perpustakaan".$folder;
$url = "http://localhost:8080/perpustakaan".$folder;
echo $url;
}
}
$proses = new proses;
$form = new input;
?>
$form = new inputClass;
16 changes: 8 additions & 8 deletions content/cetak_kembali_buku.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
<?php
include '../class/crud.php';
?>
<title>Laporan Peminjaman Buku </title>

<div class="header">
<h1>Laporan Pengembalian Buku</h1>
<h2>Perpustakaan SMK Wikrama 1 Jepara</h2>
<h2>Perpustakaan SMK Wikrama 1 Jepara</h2>
</div>

<table class="tb_isi" cellspacing="0" border="1">
Expand All @@ -19,24 +19,24 @@
<th>Denda</th>
</tr>
<?php
$sql = $proses->tampil("*","detail_pinjam,anggota,buku,pengembalian,peminjaman","WHERE pengembalian.tgl_kembali BETWEEN '$_GET[tgl1]' AND '$_GET[tgl2]' AND pengembalian.id_pinjam = detail_pinjam.id_pinjam AND peminjaman.id_anggota = pengembalian.id_anggota AND pengembalian.id_anggota = anggota.id_anggota AND buku.id_buku = detail_pinjam.id_buku AND detail_pinjam.status = 'kembali' ");
$sql = $proses->tampil("anggota.nama,pengembalian.*,buku.judul,detail_pinjam.tgl_pinjam,detail_pinjam.lama_pinjam,detail_pinjam.denda","pengembalian","INNER JOIN detail_pinjam ON pengembalian.id_pinjam=detail_pinjam.id_pinjam INNER JOIN buku ON detail_pinjam.id_buku = buku.id_buku INNER JOIN anggota ON pengembalian.id_anggota=anggota.id_anggota WHERE pengembalian.tgl_kembali BETWEEN '$_GET[tgl1]' AND '$_GET[tgl2]' AND detail_pinjam.status = 'kembali' ");
$no = 1;
foreach ($sql as $data) {
?>
<tr>
<td><?php echo $no++."."; ?></td>
<td><?php echo $data['nama']; ?></td>
<td><?php echo $data['judul']; ?></td>
<td><?php echo date('d F Y', strtotime($data[4])); ?></td>
<td><?php echo date('d F Y', strtotime($data[23])); ?></td>
<td><?php echo date('d F Y', strtotime($data['tgl_pinjam'])); ?></td>
<td><?php echo date('d F Y', strtotime($data['tgl_kembali'])); ?></td>
<td><?php echo $data['lama_pinjam']; ?></td>
<td>Rp. <?php echo number_format($data['denda'],2,",",".");?></td>
</tr>
<?php } ?>
</table>
<table class="tb_isi" border="1" cellspacing="0" style="border-top: 0px;">
<?php
$qr = $proses->tampil("SUM(detail_pinjam.denda)","detail_pinjam,anggota,buku,pengembalian,peminjaman","WHERE pengembalian.tgl_kembali BETWEEN '$_GET[tgl1]' AND '$_GET[tgl2]' AND pengembalian.id_pinjam = detail_pinjam.id_pinjam AND peminjaman.id_anggota = pengembalian.id_anggota AND pengembalian.id_anggota = anggota.id_anggota AND buku.id_buku = detail_pinjam.id_buku AND detail_pinjam.status = 'kembali' ");
<?php
$qr = $proses->tampil("SUM(detail_pinjam.denda)","pengembalian","INNER JOIN detail_pinjam ON pengembalian.id_pinjam=detail_pinjam.id_pinjam INNER JOIN buku ON detail_pinjam.id_buku = buku.id_buku INNER JOIN anggota ON pengembalian.id_anggota=anggota.id_anggota WHERE pengembalian.tgl_kembali BETWEEN '$_GET[tgl1]' AND '$_GET[tgl2]' AND detail_pinjam.status = 'kembali' ");
$jml = $qr->fetch();
?>
<tr>
Expand Down Expand Up @@ -86,4 +86,4 @@
function cetak() {
window.print();
}
</script>
</script>
12 changes: 6 additions & 6 deletions content/detail_pinjam.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
<?php
include "../class/crud.php";
$no = 1;
$qr = $proses->tampil("*","detail_pinjam","WHERE id_pinjam = '$_GET[id]'");
$qr = $proses->tampil("detail_pinjam.*,anggota.nama","detail_pinjam","INNER JOIN peminjaman ON detail_pinjam.id_pinjam = peminjaman.id_pinjam INNER JOIN anggota ON peminjaman.id_anggota = anggota.id_anggota WHERE detail_pinjam.id_pinjam = '$_GET[id]'");
$dt = $qr->fetch();
?>
?>
<!DOCTYPE html>
<html>
<head>
Expand All @@ -12,7 +12,7 @@
<body>
<div class="content">
<h1>daftar buku yang di pinjam </h1>
<p style="margin: 20px 0px -15px 0px;">ID Pinjam <?php echo $dt['id_pinjam']; ?></p>
<p style="margin: 20px 0px -15px 0px;"><b>ID Pinjam : <?php echo $dt['id_pinjam']; ?> || Nama Peminjam : <?php echo $dt['nama']; ?></b></p>
<table class="table-detail" cellspacing="0px" >
<tr>
<th>No.</th>
Expand Down Expand Up @@ -100,10 +100,10 @@
}
.content .table-detail td{
border-bottom: 1px solid #888;
height: 30px;
height: 30px;
}
.content .table-detail tr:hover{
background-color: #eeeeee;
cursor: default;
}
</style>
</style>
18 changes: 3 additions & 15 deletions content/input_pinjam.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<?php
include '../class/crud.php';
mysql_connect("localhost","root","");
mysql_select_db("db_perpustakaan");

$sql = mysql_query("SELECT MAX(id_pinjam) as kode FROM detail_pinjam")or die(mysql_error());
$dt = mysql_fetch_array($sql);
$kode = $dt['kode'];

$nu = (int) substr($kode, 3,4);
$nu++;

$char = "PNJ";
$newid = $char . sprintf("%04s",$nu);

$newid = $proses->getKodePinjam();
$date = date('Y-m-d');
$selisih = date('Y-m-d',strtotime('+7 day'));

Expand Down Expand Up @@ -71,7 +59,7 @@

<!-- Table Detail!-->
<div class="table_detail">

</div>
<!-- Table Detail!-->

Expand Down Expand Up @@ -115,4 +103,4 @@
border: 1px solid;
cursor: pointer;
}
</style>
</style>
6 changes: 3 additions & 3 deletions content/tampil_jenis_b.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
include "../class/crud.php";
?>
<h1>Data Jenis Buku</h1>
Expand All @@ -10,7 +10,7 @@
<td>
<input type="text" id="key" onkeypress="cari_enter_jenis(event)">
</td>
<td><button id="btn_cari" onkeyup="cari_jenis()">Cari</button></td>
<td><button id="btn_cari" onClick="cari_jenis()">Cari</button></td>
</tr>
</table>

Expand Down Expand Up @@ -61,4 +61,4 @@
</td>
</tr>
<?php } ?>
</table>
</table>
18 changes: 9 additions & 9 deletions content/tampil_pinjam.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
include "../class/crud.php";
?>
<h1>Data Peminjaman Buku</h1>
Expand All @@ -22,25 +22,25 @@
<th>Tanggal Transaksi</th>
<th>Total Pinjam</th>
<th>ID Anggota</th>
<th>Nama</th>
<th>Action</th>
</tr>
<?php
$tamp = $proses->tampil("*",
$tamp = $proses->tampil("peminjaman.*,nama",

"peminjaman",

"");
"INNER JOIN anggota ON peminjaman.id_anggota = anggota.id_anggota");

$no=1;
foreach ($tamp as $data) {

?>
foreach ($tamp as $data) {?>
<tr>
<td><?php echo $no++."."; ?></td>
<td><?php echo $data[0]; ?></td>
<td><?php echo $data[1]; ?></td>
<td><?php echo $data[2]; ?></td>
<td><?php echo $data[3]; ?></td>
<td><?php echo $data['nama']; ?></td>
<td width="180px">

<div class="hapus" onclick="hapus_pinjam('<?php echo $data['id_pinjam']; ?>')"><p>Hapus</p></div>
Expand All @@ -50,9 +50,9 @@
Detail
</button>
</a>

<div class="tmb_pinjam" onclick="tmb_pinjam('<?php echo $data['id_pinjam']; ?>','<?php echo $data['id_anggota']; ?>')"><p>+</p></div>
</td>
</tr>
<?php } ?>
</table>
</table>
9 changes: 4 additions & 5 deletions proses/p_s_kembali.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
<?php
include "../class/crud.php";
$status = "kembali";
$sqlp = $proses->tampil("*","pengembalian","WHERE id_pinjam = '$_POST[id_pinjam]' ");
$d = $sqlp->fetch();
$jml_denda = $d['jumlah_denda']+$_POST['jumlah_denda'];
$jml_denda = @$d['jumlah_denda']+$_POST['jumlah_denda'];
$rowp = $sqlp->rowCount();

$qr = $proses->tampil("*","detail_pinjam","WHERE id_pinjam = '$_POST[id_pinjam]' AND status = 'pinjam'");
Expand Down Expand Up @@ -39,7 +39,7 @@
denda = '$_POST[denda]'","
id_detail_pinjam = '$_POST[id_detail_pinjam]'");
$kembalikan = $proses->simpan("pengembalian","
'',
NULL,
'$_POST[tgl_kembali]',
'$_POST[denda]',
'$_POST[id_anggota]',
Expand All @@ -52,12 +52,11 @@
denda = '$_POST[denda]'","
id_detail_pinjam = '$_POST[id_detail_pinjam]'");
$kembalikan = $proses->simpan("pengembalian","
'',
NULL,
'$_POST[tgl_kembali]',
'$_POST[denda]',
'$_POST[id_anggota]',
'$_POST[id_pinjam]' ");
echo "berhasil";
}
}
?>
6 changes: 3 additions & 3 deletions proses/p_simpan_buku.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
<?php
include "../class/crud.php";
$simpan = $proses->simpan("buku","
'',
NULL,
'$_POST[judul_buku]',
'$_POST[penerbit_buku]',
'$_POST[thn_terbit_buku]',
Expand All @@ -10,4 +10,4 @@
'$_POST[stok_buku]'
");
echo "Berhasil";
?>
?>
11 changes: 5 additions & 6 deletions proses/p_simpan_dtl_pinjam.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php
<?php
include "../class/crud.php";
$status = "pinjam";
$lama_pinjam = "0";
$denda = "0";

$sql = $proses->tampil("detail_pinjam.id_buku","detail_pinjam","WHERE detail_pinjam.id_pinjam = '$_POST[id_pinjam]' AND detail_pinjam.id_buku = '$_POST[id_buku]' AND detail_pinjam.status = 'pinjam'");
$data = $sql->fetch();
$id_buku = $_POST['id_buku'];

if ($id_buku == $data['id_buku']) {
if ($_POST['id_buku'] === @$data['id_buku']) {
echo "Gagal";
}else{
$s_detail = $proses->simpan("detail_pinjam","
'',
$proses->simpan("detail_pinjam","
NULL,
'$_POST[id_pinjam]',
'$_POST[id_buku]',
'$_POST[jumlah]',
Expand All @@ -23,4 +22,4 @@
'$denda'");
echo "Berhasil";
}
?>
?>
6 changes: 3 additions & 3 deletions proses/p_simpan_jenis.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
<?php
include '../class/crud.php';
$simpan = $proses->simpan("jenis","
'',
NULL,
'$_POST[nama_jenis_b]',
'$_POST[keterangan_b]'");
echo "Berhasil";
?>
?>
8 changes: 3 additions & 5 deletions proses/p_simpan_pinjam.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?php
<?php
include "../class/crud.php";

$sql = $proses->tampil("*","peminjaman,detail_pinjam","WHERE peminjaman.id_anggota = '$_POST[id_anggota]' AND detail_pinjam.id_pinjam = peminjaman.id_pinjam AND detail_pinjam.status = 'pinjam'");
$data = $sql->fetch();

$id_anggota = $_POST['id_anggota'];

if ($id_anggota == $data['id_anggota']) {
if ($_POST['id_anggota'] === @$data['id_anggota']) {
echo "Gagal";
}else{
$simpan = $proses->simpan("peminjaman","
Expand All @@ -16,4 +14,4 @@
'$_POST[id_anggota]'");
echo "Berhasil";
}
?>
?>
10 changes: 5 additions & 5 deletions table/lap_kembali_buku.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
include '../class/crud.php';
?>
<table class="table1" cellspacing="0" >
Expand All @@ -12,17 +12,17 @@
<th>Denda</th>
</tr>
<?php
$sql = $proses->tampil("*","detail_pinjam,anggota,buku,pengembalian,peminjaman","WHERE pengembalian.tgl_kembali BETWEEN '$_POST[tgl1]' AND '$_POST[tgl2]' AND pengembalian.id_pinjam = detail_pinjam.id_pinjam AND peminjaman.id_anggota = pengembalian.id_anggota AND pengembalian.id_anggota = anggota.id_anggota AND buku.id_buku = detail_pinjam.id_buku AND detail_pinjam.status = 'kembali' ");
$sql = $proses->tampil("anggota.nama,pengembalian.*,buku.judul,detail_pinjam.tgl_pinjam,detail_pinjam.lama_pinjam,detail_pinjam.denda","pengembalian","INNER JOIN detail_pinjam ON pengembalian.id_pinjam=detail_pinjam.id_pinjam INNER JOIN buku ON detail_pinjam.id_buku = buku.id_buku INNER JOIN anggota ON pengembalian.id_anggota=anggota.id_anggota WHERE pengembalian.tgl_kembali BETWEEN '$_POST[tgl1]' AND '$_POST[tgl2]' AND detail_pinjam.status = 'kembali' ");
$no = 1;
foreach ($sql as $data) {
?>
<tr>
<td><?php echo $no++."."; ?></td>
<td><?php echo $data['nama']; ?></td>
<td><?php echo $data['judul']; ?></td>
<td><?php echo date('d F Y', strtotime($data[4])); ?></td>
<td><?php echo date('d F Y', strtotime($data[23])); ?></td>
<td><?php echo $data['lama_pinjam']; ?></td>
<td><?php echo date('d F Y', strtotime($data['tgl_pinjam'])); ?></td>
<td><?php echo date('d F Y', strtotime($data['tgl_kembali'])); ?></td>
<td><?php echo $data['lama_pinjam']; ?> Hari</td>
<td>Rp. <?php echo number_format($data['denda'],2,",",".");?></td>
</tr>
<?php } ?>
Expand Down
Loading

0 comments on commit 8347051

Please sign in to comment.